試圖在這裏編寫一個LINQ查詢來從T SQL中複製NOT IN。這裏是我想要在LINQ中的SQL查詢:不是子選擇從T SQL到LINQ?
select * from schema.Table1
where TableId NOT IN (select pa.TableId from schema.Table2 ta
where ta.SecondaryId = myParameter)
看看以前的帖子,但還沒有完全得到它的工作。
var query = from a in _Context.Table1
where a.TableId != _Context.Table2.Any(ta=>(ta.SecondaryId== myParameter))
select a;
店Table2.TableId列表中的等價,然後更改的LINQ to是這樣的:'哪裏idList.Any(X => X == a.TableId )'或'idList.All(x => x!= a.TableId)' – Reniuz
由於@Christos概述的問題以及其他巨大的bug和缺失的功能,我會建議不要使用LinqToSQL。 – Aron