これが私のSQLクエリです:
Select <a bunch of columns>
from fields f
join Table1 c1 on c1.fieldID = f.ID and c1.year = 2014
join Table2 fRes on f.ID = fRes.fieldID
join Table3 stst on f.ID = stst.fieldID
join Table4 model on c1.ID = model.yearID
left join Table5 fA on f.ID = fA.fieldID and fA.year = 2014
left join Table6 nA on f.ID = nA.fieldID and nA.year = 2014
where fA.sourcename IS NULL and nA.Sourcename IS NULL
LINQ to SQL:
from f in BasicDataAccess.Data.FieldsList
join c1 in BasicDataAccess.Data.Table1List on f.ID equals c1.fieldID
join fRes in BasicDataAccess.Data.Table2List on f.ID equals fRes.fieldID
join soilTst in BasicDataAccess.Data.Table3List on f.ID equals soilTst.fieldID
join modelRsNM in BasicDataAccess.Data.Table4List on c1.ID equals modelRsNM.YearID
join fA in BasicDataAccess.Data.Table5List on f.ID equals fA.fieldID into group1
from g1 in group1.Where(fA => fA.Year == reportYear).DefaultIfEmpty()
join nA in BasicDataAccess.Data.Table6List on f.ID equals nA.fieldID into group2
from g2 in group2.Where(nA => nA.Year == reportYear).DefaultIfEmpty()
where g1.sourceName == null && g2.sourceName == null
問題: クエリを実行すると、Nullreference 例外が処理されませんでした..オブジェクト参照がオブジェクトのインスタンスに設定されていません..
私は何が欠けていますか?where句で左外部結合テーブルを参照することはできますか? 助けてください!