6

私のSQLコードは次のとおりです。

select UserId,UserName 
from aspnet_Users 
where UserId not in (select UsersId from tbluser  where active='true')

同等のlinq式は何ですか?

4

2 に答える 2

11

私の最初の使用LiNQを試みます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};

ソース

于 2012-12-22T09:21:53.417 に答える
0
var query =
    from c in aspnet_Users 
    where !(from o in tbluser where o.active=="true" 
            select o.UserId)
           .Contains(c.UserId)
    select c;
于 2012-12-22T09:28:33.010 に答える