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开发者_如何学Python.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.
精彩评论