我有一个LINQ查询使用连接,我没有足够的LINQ知识我想在SQL中转换此查询请帮助我谢谢。 在我发布LINQ查询的代码中,请帮我在sql中转换这个查询。
var secUserList = (from secUser in dc.sec_users
join userRoles in dc.sec_user_roles
on secUser.user_id equals userRoles.user_id
join secUserAuth in dc.sec_user_authentications
on secUser.user_id equals secUserAuth.user_id
where userRoles.role_id == roleId
orderby secUser.first_name
select new { secUser, secUserAuth });
答案 0 :(得分:3)
这是非常直接的,不是吗?
SELECT secUser.*, secUserAuth.*
FROM sec_users secUser
INNER JOIN sec_user_roles userRoles
ON secUser.user_id = userRoles.user_id
INNER JOIN sec_user_authentications secUserAuth
ON secUser.user_id = secUserAuth.user_id
WHERE userRoles.role_id = roleId
ORDER BY secUser.first_name