简体   繁体   中英

Linq Error on Left outer join

i have an alert table that has a 1:many mapping to devices. 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.

 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.

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. I think that is where it is failing since it cannot get the properties/variables from null.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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