我有一個名爲MyList的int列表;它來自於linq到sql查詢的結果。 我有一個名爲ExistingObjectsList的MyObject的列表,其中包含一個int作爲其屬性之一。加入null找到缺失的元素
我正在創建一個新列表,其中包含MyObjectsList中但不包含MyList中的所有整數。
這是我到目前爲止有:
var NewObjects = (from obj in MyObjectsList
join x in ExistingObjectsList on
obj.ID equals x into outer
from o in outer
where o == null
select o).ToList();
我敢肯定,這是簡單的,但此刻它不工作。
感謝您的建議。
你想從MyObjectsList或ExistingObjectsList的對象? – Magnus 2011-06-07 19:06:38
您是否嘗試過使用聯合並獲取不同的對象。 (http://msdn.microsoft.com/en-us/library/bb386993.aspx) – 2011-06-07 19:07:05