有人可以帮助我从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提示每个表格。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top