.net – linq等效的sql查询“不在(选择查询)”

前端之家收集整理的这篇文章主要介绍了.net – linq等效的sql查询“不在(选择查询)”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的sql代码如下: @H_404_2@select UserId,UserName from aspnet_Users where UserId not in (select UsersId from tbluser where active='true')

什么是等效的linq表达式?

解决方法

我第一次尝试在C#中使用LiNQ @H_404_2@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};

资源

> The NOT IN clause in LINQ to SQL

猜你在找的MsSQL相关文章