这是我的查询:
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 }
如果 fA == null,我得到对象引用 null 异常。我正在对 fA 进行左连接,因此它可能为空值或非空值。如何重写这部分查询,以便在 fA 为空时查询不会引发异常。
非常感谢!