linq not in 查询
类别:编程学习 浏览量:1394
时间:2015-11-4 linq not in 查询
linq not in 查询下面以linq to sql的实例介绍 not in 查询和 in查询,linq的用法类似
一、T-SQL的IN
Select ProductID, ProductName, CategoryID
From dbo.Products
Where CategoryID in (1, 2)
二、LINQ to SQL 实现IN
var queryResult = from p in db.Products
where (new int[] {1,2}).Contains(p.CategoryID)
select p;
三、T-SQL的NOT IN
Select ProductID, ProductName, CategoryID
From dbo.Products
Where CategoryID not in (1, 2)
四、LINQ to SQL 实现 NOT IN
var queryResult = from p in db.Products
where !(new int[] {1,2}).Contains(p.CategoryID)
select p;
五、LINQ to SQL 实现 NOT IN子查询
from a in TableA where !(from b in TableB Where ... select b.Id).Contains(a.Id)
六、Linq 实现方式
//比如 Id in (1,2,3)
int[] a={1,2,3};
list.Where(x=>a.Contains(x.Id))
标签:linq
您可能感兴趣
- Linq操作Datable
- 使用 LINQPad 调试linq以及lambda表达式
- Linq中where查询
- linq中延迟执行
- LINQ TO SQL 中join
- linq中join用法
- Linq中的TakeWhile和SkipWhile
- datatable linq查询
- linq to sql 中Concat、Union、Intersect、Except
- linq distinct去重
- LINQ中Aggregate的用法
- linq not in 查询
- Linq中select查询
- linq xml 查询
- linq中AsEnumerable和AsQueryable的区别
- list使用linq排序
- ()
- 百事大吉蓝底 绿底手机高清壁纸(绿底手机高清壁纸)
- 蓝底证件照怎么制作 证件照换底色 换尺寸快速搞定(蓝底证件照怎么制作)
- 你喜欢足球吗 足球如何点亮世界的(足球如何点亮世界的)
- 不可分鸽是什么梗(不可分鸽是什么梗)
- 古代的鸽子是爱情的象征,并非和平的使者(古代的鸽子是爱情的象征)
热门推荐
- Visual Studio的browser link
- php微信公众号管理后台(php实现微信公众号创建自定义菜单功能的实例代码)
- sqlserver数据库还原教程(SQL Server通过重建方式还原master数据库)
- c#中list排序
- mysql怎么建立主键外键(mysql 实现设置多个主键的操作)
- php7用什么替代mysql(mysqli扩展无法在PHP7下升级问题的解决)
- CSS中Position 的用法
- mysql存储过程和函数(MySQL存储过程的查询命令介绍)
- sqlserver创建表结构时添加约束(SQL Server 通过with as方法查询树型结构)
- python数字形式转换详解(Python3.5实现的罗马数字转换成整数功能示例)