SQL not in 转化为Linq

来源:互联网 发布:程序员挣钱的五种方法 编辑:程序博客网 时间:2024/05/29 16:36

SQL语句:


 select * from QY_Business where StatusID=1 and  BusinessID not in(select OtherBusinessID from QY_BusinessAssignConsumePlaceDetail where StatusID =1)

Linq语句:

var result = db.QY_Business.Where(c => c.StatusID == 1 &&!(from y in db.QY_BusinessAssignConsumePlaceDetailwhere y.StatusID == 1 select y.OtherBusinessID).Contains(c.BusinessID));