LINQ相当于SQL查询"不是(选择查询)" [英] linq equivalent sql query "not in (select query)"

查看:201
本文介绍了LINQ相当于SQL查询"不是(选择查询)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的SQL code是如下:

my sql code is as follows:

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

什么是相当于LINQ EX pression?

what is the equivalent linq expression?

推荐答案

我的第一次尝试 C#使用 LINQ

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};

来源

  • <一个href="http://programminglinq.com/blogs/marcorusso/archive/2008/01/14/the-not-in-clause-in-linq-to-sql.aspx">The NOT IN在LINQ子句SQL

这篇关于LINQ相当于SQL查询&QUOT;不是(选择查询)&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆