Reputation: 8192
The good thing about the entity framework is, that it hides the complete n..m association problem.
Now I have some really simple Database containing
Person (Id, Name)
Profession (Id, Designation)
there is a n..m association between those two, meaning every person can have many Professions and every Profession can be executed by many Persons. This association is built on the Id in each entity.
Now I want to have exactly those Associations, but there seems to be no way to get those.
If I query a Person like
using (PersonDataModelContainer dmc = new PersonDataModelContainer())
{
var persons = (from p in dmc.Persons
where p.Id == personId
select p).ToList();
}
There is a member "Profession", but it is empty. In the Associationstable there are entries that correspond to this Person.Id.
I see somewhere down in the single object this query returns that there are the relations in a non public member.
How can I read those? Should not be that hard I believe, but I could not find it out via google.
Upvotes: 0
Views: 269
Reputation: 44048
using (PersonDataModelContainer dmc = new PersonDataModelContainer())
{
var persons = dmc.Persons
.Include("Profession")
.Where(p.Id == personId)
.ToList();
}
Upvotes: 1