سؤال

هل يمكن لشخص مساعدتي على التحويل من SQL Query إلى 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