views:

71

answers:

2

I have a Users table, Events table, and a mapping of UserEvents. In some parts of my code, I just need user-based stuff. In other parts, I need all of this information. (Especially: given a user, what are the details of each event they are subscribed to?)

If I have one repository just for users and another for users + events + userevents, then the auto-created users object is duplicated and the code won't compile until I rename one of them. This is possible but inconvenient. On the other hand, if I only have one repository with all 3 tables, when I just want user info, will it be expensive due to linq getting all the associated data with that user id?

In Linq2Sql, is it more expensive if you have more tables in a single dbml/repository?

+1  A: 

Linq2Sql uses lazy loading to get additional information. I believe it can be configured to fetch all at once, but that is not the default behavior. If you ask for a user, you will not get events unless you specifically ask for them.

Brian
+1  A: 

I have a project with 100+ tables in the dbml, as far as I can tell this does not effect the the time to instanciate the datacontext class.

Flores