Need a Linq query for a matching Sql query

advertisements

Basicall I have three Tables Users Roles and USerRoles with Many to many Relationship. So when I import these on .edmx i get only two Entities. so i have Navigation Properties in both Entities. I have three Users and 2 Roles (admin and ReadOnly). So Now I want to fetch all USers who has admin role. Below is my Sql Query

select U.UserName from Users U
Inner Join UserRoles UR on U.UseID = UR.UserId where UR.RoleId = 1

I want above in Linq query.


Something like this:

users.Include("Roles").Where(u => u.Roles.Any(x => x.Id == 1))