LINQ where子句中的SELECT语句不
-
19-09-2019 - |
题
有人可以帮助我从SQL查询转换为LINQ VB.NET:
select rls.* from Roles rls(nolock)
where rls.id not in (
select r.ID from usersRole ur (nolock)
inner join Roles r(nolock) on ur.RoleID = r.ID
where user_id = 'NY1772')
由于
没有正确的解决方案
其他提示
我找到我自己的答案......
'construct a where ID list
Dim lstRoleIDs = From ur In ctx.UsersRoles _
Join rl In ctx.Roles _
On ur.RoleID Equals rl.ID _
Where ur.User_ID = UserId _
Select rl.ID
Dim newQ = (From r In ctx.Roles _
Where Not lstRoleIDs.Contains( _
r.ID) _
Select New UserRoleList With {.ID = r.ID, .PermDesc = r.ID & " - " & r.Permission & " - " & r.PermissionDescription})
如果您希望保留(NOLOCK)提示,我的博客一个方便的溶液使用C#扩展方法。注意,这是与在所述查询中添加NOLOCK提示每个表格。
不隶属于 StackOverflow