将此SQL查询转换为LINQ to SQL

时间:2011-11-25 07:23:04

标签: entity-framework linq-to-sql

select aspnet_Users.UserName from aspnet_Users,aspnet_UsersInRoles, aspnet_Roles
where aspnet_UsersInRoles.RoleId=aspnet_Roles.RoleId
and
  aspnet_UsersInRoles.UserId=aspnet_Users.UserId
and
  aspnet_Roles.RoleName='abc'

1 个答案:

答案 0 :(得分:1)

from user in DbContext.Users
where user.UsersInRoles.Any(uir=>uir.Role.RoleName=="abc")
select user.UserName