LINQ 위치 조항은 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