0
任何想法如何將其轉換爲LINQ?如何將嵌套NOT EXISTS查詢轉換爲LINQ
SELECT DISTINCT PartNumber AS [PartNumber That Includes EVERY ItemNumber Listed in @RequiredItemsTable]
FROM Part.BillsOfMaterialsFlattened AS bom1
WHERE NOT EXISTS
(SELECT *
FROM @RequiredItemsTable w
WHERE NOT EXISTS
(SELECT *
FROM Part.BillsOfMaterialsFlattened AS bom2
WHERE (bom1.PartNumber = bom2.PartNumber)
AND (bom2.ItemNumber = w.ItemNumber)));
我已經看到了這個網站的幾個例子,試圖模仿他們....但到目前爲止還沒有到達那裏。
謝謝!
下面是我正在尋求通過linq實現的表格示例。上述T-SQL可以做到這一點。
Part.BillsOfMaterialsFlattened
PartNumber ItemNumber
10041047 10034480
10041047 10041090
10041047 10041091
10041048 10034480
10041048 10041091
10041049 10034650
10041049 10041090
10041049 10041091
10041050 10034650
10041050 10041091
10041061 10001331
10041061 10001422
@RequiredItemsTable
ItemNumber
10041090
10041091
想LINQ語句來生成IQueryable<String>
PartNumber (Part Numbers that include all Required Item Numbers)
10041047
10041049
您所做的一切? – Jorge
試圖按照這篇文章:http://stackoverflow.com/questions/899090/linq-where-not-exists – CalvinDale
我試圖按照這篇文章中概述的技術:http://stackoverflow.com/questions/899090/ linq-where-not-exist存在這個代碼......好吧,我有很多行註釋掉了,我不確定哪個集合完全模擬了這種技術。我也看了這篇文章:http://stackoverflow.com/questions/2114342/convert-this-sql-query-to-linq-not-exists-sub-query我對它的重組技術感興趣將代碼放入可縮短的謂詞中。我以前從未聽說過「sargable」(我有機械工程背景)。我想要一個非常有效的linq查詢。 – CalvinDale