2010-09-29 104 views
1

我有一個警告表,它具有1:多映射到設備。這種關係是在一個映射表中傳遞的。當我嘗試產生從映射表到各種資產類型表的左外連接時,出現以下錯誤:System.Security.VerificationException:操作可能會破壞運行時的穩定性。左外連接上的Linq錯誤

var alertAssets = (from a in dc.MSAlert_Assets 
           from b in dc.MSRfids.Where(x => x.accountID == a.accountID && x.rfID == a.tagNum && x.custNum == a.custNum).DefaultIfEmpty() 
           from c in dc.MSDevices.Where(x => x.accountID == a.accountID && x.deviceID == a.deviceID).DefaultIfEmpty() 
           from d in dc.MSGroups.Where(x => x.accountID == a.accountID && x.groupID == a.groupID).DefaultIfEmpty() 
           let x = grrepo.getAssetsForGroupID(d.groupID, d.accountID) 
           where a.alertID == alertID 
           select new {... specific objects} 

我想這可能是一個縮小的問題,所以我Enumarated的IQueryable的,但還是同樣的問題。

+0

你試過使用連接而不是from和where子句 – 2010-09-29 16:56:55

回答

0

一件事情跳出我是行

let x = grrepo.getAssetsForGroupID(d.groupID, d.accountID) 

如果d可以爲空值(因爲它是一個左外連接,因爲DefaultIfEmpty的),那麼你怎麼能訪問d.groupID或d.accountID。我認爲這是失敗的地方,因爲它無法從null獲得屬性/變量。