views:

260

answers:

1

I initially thought that using a view would be the best option because I've already encapsulated every column that I want in it.

However, after closer inspection, it seems that adding just tables (and using the built-in relationships that are already created) is a much cooler way to do it because those relationships cause LINQ to SQL to create COLLECTIONS within the objects. "Customer" gets an automatic "Orders" collection, just because there's a foreign key relationship between them. That's something that a flat view won't give me.

What are most people querying, tables or views?

A: 

You're not really comparing apples to apples. True, the L2S collections are great, but your views probably already have these built in. If you need to do a varied number of LINQ queries, with strong type checking, having L2S model the table relationships is great. And, if you need to persist data, the L2S model is necessary. However, if all your queries hit views, and you don't need to persist data, you probably don't need the L2S model.

Randy

Randy Minder