Here’s my query:
from f in DataAccess.Data.FList
join fA in DataAccess.Data.FAppsList on f.ID equals fA.fID into fApps
from fA in fApps.Where(fA => fA.Year == reportYear).DefaultIfEmpty()
join fSrc in DataAccess.Data.FSourcesList on new { ID = fA.sourceID, CropYear = reportYear }
equals new { ID = fSrc.ID, CropYear = fSrc.CropYear }
I get Object reference null exception if fA == null. I am doing a left join on fA so it could be either null or not null value. How do I rewrite this section of query so that the query does not throw exception if fA is null.
Thanks much!
The common construct in the ternary conditional operator (
?:) which can be used to safeguard invoking a member on anull-valuedexpression is:In context: