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

linq 中如何表达 SQL中的 not in

2012-11-05 
linq 中怎么表达SQL中的 not inselect * from stuInfo where stuNo not in(select stuNo from StuMarks)怎

linq 中怎么表达 SQL中的 not in
select * from stuInfo where stuNo not in(select stuNo from StuMarks)
怎么用 Linq 进行书写。 求解谢谢!


[解决办法]
all的写法:
var query = db.stuInfo.Where(x => db.StuMarks.All(y => y.stuNo != x.stuNo));

join的写法

C# code
var query = from x in db.stuInfo            join y in db.StuMarks on x.stuNo equals y.stuNo into j            from item in j.DefaultIfEmpty(default(StuMark类型))            where item == default(StuMark类型)            select x; 

热点排行