I have a database with a User's and Role's table. Each user can be in lots of roles, so there is a 'middle' table called UserRoles that simply contains a RoleId and UserId.
Now I need to get all the roles attached to a User.
public IEnumerable<Role> GetAllRoles(int UserId)
{
var query = from R in _db.Roles
where RolesTbl.UserRoles.UserId == UserId
select R;
return query;
}
Now the query above doesnt work, "RolesTbl.UserRoles.UserId" I cant referance it in this way because of the Many to Many.
Anyone have a suggestion on how to resolve?