下面的查詢失敗,空引用異常當有BOMIDs元素,其中材質ID屬性是什麼。 我以爲'x.MatID isnot Nothing AndAlso'會阻止執行的地方的x.MatID.Process部分。 BOMIDs集合中有幾個元素,其中MatID什麼也沒有。 有什麼想法?AndAlso在VB Linq查詢,似乎並不奏效
From x In BOMIDs _
Group Join y As PurchasedProcess In SpecialProcesses _
On x.MatID.PurchasedProcess Equals y.Name _
Into G = Group _
From z In G.DefaultIfEmpty() _
Where x.MatID IsNot Nothing AndAlso _
x.MatID.Process = ProcessEnum.PurchasedProcess _
Select New With {.Item = x.Item, .Process = z}
這工作很好,謝謝。仍然習慣Linq,我認爲我的頭被困在SQL中。 – Kratz 2010-09-14 17:44:42