lzth.net
当前位置:首页 >> linq whErE not in >>

linq whErE not in

T-SQL的 IN:Select ProductID, ProductName, CategoryIDFrom dbo.ProductsWhere CategoryID in (1, 2)T-SQL的 NOT IN:Select ProductID, ProductName, CategoryIDFrom dbo.ProductsWhere CategoryID not in (1, 2)//-------------------------...

var query = from _a in db.a where !(from _b in db.b select _b.id).Contains(_a.id) select _a;

select TOP 4*from Examine where ExamineLevel not in(select LinkLevel from Link where LinkClubId==3) --not in 把where条件改成不等于3就好啦 and ExamineTypeId not in(select LinkExamineTypeId from Link where LinkClubId==3 ) --not i...

那个 提示下 Linq本身 确实可以实现 sql select... where in 操作 但是好像效率不太好 我个人排斥 直接给出答案 折集合对象 class myitem { int id; string name;‍ } var myitemcollection = new myitem[]{ ....... }; //要找出 id 等于 1...

var result = from a in A表 join b in B表 on a.某字段 equals b.某字段 select new { a.XXX, b.XXX }; 或者 var result = from a in A表 from b in B表 where a.某字段 == b.某字段 select new { a.XXX, b.XXX };

用Contains()方法; 首先获取t2.id这个对象 假如这个id=2 假如表是User var item=from u in ctx.user where u.id=2; 再判断 bool isexists= ctx.user.Contains(item);

var queryResult = from p in db.major where ! (new int?[] {1,2}).Contains(p.mld) select p;

var query =from city in db.Cities where !db.Countries.Any(country => country.ID == city.ID) select city; 返回不存在于 Countries中但存在于cities中的city。 参考着写吧。

List arr = new List(); arr.Add(1);arr.Add(2); query.Where(c => arr.Contains(c .UserID));

int[] array = {20,10,11,...}; var result = from p in table1 where array.Contains(p.id) select p; 大概是这样,因为手头上没有VS,所以不保证100%准确。关键是扩展方法Contains的使用。

网站首页 | 网站地图
All rights reserved Powered by www.lzth.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com