I have a many-to-many relationship defined like so:
Employees
--------------
EmployeeID (PK)
Roles
--------------
RoleID (PK)
EmployeeRoles
--------------
EmployeeID (PK, FK)
RoleID (PK, FK)
I'm trying to get a list of Employees, given a list or RoleIDs:
private MyDBEntities _entities;
public SqlEmployeesRepository(MyDBEntities entities)
{
_entities = entities;
}
public IQueryable<Employee> GetEmployeesForRoles(int[] roleIds)
{
// get employees
}
But if I try and do _entities.EmployeeRoles
, there is no EmployeeRoles object. My edmx looks like this:
So it's recognizing the relationship between the two tables, but it's not creating an entity object for EmployeeRoles.
How can I get a distinct list of Employees given a list of role id's?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…