首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Linq Not in,该怎么处理

2012-09-21 
Linq Not inDataTable:t:idWRWR10W01W011W02null2W03W033W03null4null null查询 WR1中没有的WR:也就是sele

Linq Not in
DataTable:

t:
id WR WR1
0 W01 W01
1 W02 null
2 W03 W03
3 W03 null
4 null null

查询 WR1中没有的WR:也就是

select WR from t 
where WR not in (select WR1 from t)

用Linq怎么实现?

[解决办法]

C# code
var query=from dt in t.AsEnumerable()          where !t.AsEnumerable().Select(x=>x.Field<string>("WR1")).Contains(dt.Field<string>("WR"))           select dt.Field<string>("WR"); 

热点排行