mój kod SQL jest następujący:LINQ kwerendy SQL odpowiednikiem "nie (select query)"
select UserId,UserName
from aspnet_Users
where UserId not in (select UsersId from tbluser where active='true')
co jest odpowiednikiem wyrażenie LINQ?
mój kod SQL jest następujący:LINQ kwerendy SQL odpowiednikiem "nie (select query)"
select UserId,UserName
from aspnet_Users
where UserId not in (select UsersId from tbluser where active='true')
co jest odpowiednikiem wyrażenie LINQ?
moja pierwsza próba z użyciem LiNQ
w C#
var result = from y in aspnet_Users
where !(
from x in tblUser
where x.active == "true"
select x.UsersID
).Contains(y.UserId)
select y;
-- OR // select new { y.UserId, y.UserName};
SOURCE
Myślę, że powinno to być 'x.active' –
@Sahuagin yep, thanks. –
+1 dla źródła. –
var query =
from c in aspnet_Users
where !(from o in tbluser where o.active=="true"
select o.UserId)
.Contains(c.UserId)
select c;
Jak twoja ** kopia ** różni się od odpowiedzi @ JW? –
Nie zauważyłem odpowiedzi @jw, po zaksięgowaniu mojej odpowiedzi wtedy dowiedziałem się, że oba są takie same. – LNRao
'gdzie! Aspnet_Users.Any (p => p.active ==" true ")' nie wygląda tak samo. Czy coś mi umyka? –
! .Contains() lub() .Except są dwa sposoby, ja” m świadomy – dougajmcdonald
w 'VB' lub' C# '? –