I'm trying EF out and I do a lot of filtering based on many to many relationships. For instance I have persons, locations and a personlocation table to link the two. I also have a role and personrole table.
EDIT: Tables:
Person (personid, name)
Personlocation (personid, locationid)
Location (locationid, description)
Personrole (personid, roleid)
Role (roleid, description)
EF will give me persons, roles and location entities. EDIT: Since EF will NOT generate the personlocation and personrole entity types, they cannot be used in the query.
How do I create a query to give me all the persons of a given location with a given role?
In SQL the query would be
select p.*
from persons as p
join personlocations as pl on p.personid=pl.personid
join locations as l on pl.locationid=l.locationid
join personroles as pr on p.personid=pr.personid
join roles as r on pr.roleid=r.roleid
where r.description='Student' and l.description='Amsterdam'
I've looked, but I can't seem to find a simple solution.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…