views:

107

answers:

1

I have three tables Projects, Users and ProjectMembers. The ProjectMembers table is a mapping table and has only two columns ProjectId and UserId.

In my object model i have two classes Project and User. The Project class has a property IEnumerable<User> Members

I am using an external xml map file for mapping linq to sql associations. I am able to get the Project and the User data but I dont know how to map the Members association.

+3  A: 

This sounds like a Many-to-Many mapping (Projects <-> Users).

In which case you are going to run into problems using Linq To SQL. To cut a long story short it does not really support that mapping. There are several workarounds which you can find on google, one of which is altering the partial class to provide the access to the Members/Projects collection on the Project and User classes respectively.

e.g. http://www.iaingalloway.com/many-to-many-relationships-in-linq-to-sql

Schneider