简体   繁体   English

左外部联接上的Linq错误

[英]Linq Error on Left outer join

i have an alert table that has a 1:many mapping to devices. 我有一个警报表,其中有一个1:许多映射到设备的表。 This relationship is conveyed ina mapping table. 此关系在映射表中传达。 When I try to produce a left outer join from the mapping table to the various asset type tables i get the following error:System.Security.VerificationException: Operation could destabilize the runtime. 当我尝试从映射表到各种资产类型表生成左外部联接时,出现以下错误:System.Security.VerificationException:操作可能会使运行时不稳定。

 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}

I thought it may be a narrowing issue, so i Enumarated the IQueryable, but still the same issue. 我认为这可能是一个缩小的问题,因此我对IQueryable进行了编号,但仍然是相同的问题。

The one thing that jumps out at me is the line 跳到我身上的一件事是线

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

If d can be null (since it's a left outer join because of the DefaultIfEmpty), then how can you access the d.groupID or the d.accountID. 如果d可以为null(由于DefaultIfEmpty而由于它是左外部联接),那么如何访问d.groupID或d.accountID。 I think that is where it is failing since it cannot get the properties/variables from null. 我认为那是失败的地方,因为它无法从null获得属性/变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM