2 つの左結合で LINQ クエリを実行しても問題ありませんが、3 番目の左結合を追加すると、「from」の最初のテーブルが 3 番目の左結合で使用できなくなり、エラーが発生します。
Source compile error, line ##: The name 'x' does not exist in the current context
例えば:
from x in [TableX]
join a in [TableA]
on x.ItemNumber equals a.ItemNumber into aLeftJoin
from aLeft in aLeftJoin.DefaultIfEmpty()
join b in [TableB]
on x.ItemNumber equals b.ItemNumber into bLeftJoin
from bLeft in bLeftJoin.DefaultIfEmpty()
join c in [TableC]
on x.ItemNumber equals c.ItemNumber into cLeftJoin
from cLeft in cLeftJoin.DefaultIfEmpty()
select new
{
x.ItemNumber,
...
}
次に、オンラインでエラーが発生しon x.ItemNumber equals c.ItemNumber into cLeftJoin
、左の結合を並べ替えても問題ありません.3番目の結合でもエラーが発生します。