SQL 内连接查询:
Select
r.RoleName
From
webpages_Roles r
Inner Join
webpages_GroupInRoles gr ON r.RoleID = gr.RoleId
Inner Join
webpages_UsersInGroup ug ON gr.GroupID = ug.GroupID
Where
ug.UserID = 1
我正在尝试将此 SQL 转换为使用 EF 的扩展连接 3 个表:
var q1 = db.webpages_Roles
.Join(db.webpages_GroupInRoles,
r => r.RoleId,
gr => gr.RoleID,
(r, gr) => r)
.Join(db.webpages_UsersInGroup,
ug => ug.GroupID,
gr=>gr.GroupID,
(ug, gr) => ug);