LINQ to SQL - 具有多個(gè)連接條件的左外連接我有以下SQL,我試圖將其轉(zhuǎn)換為LINQ:SELECT f.valueFROM period as p LEFT OUTER JOIN facts AS f ON p.id = f.periodid AND f.otherid = 17WHERE p.companyid = 100我已經(jīng)看到了左外連接的典型實(shí)現(xiàn)(即into x from y in x.DefaultIfEmpty()等),但我不確定如何引入其他連接條件(AND f.otherid = 17)編輯為什么AND f.otherid = 17條件是JOIN的一部分而不是WHERE子句?因?yàn)閒某些行可能不存在,我仍然希望包含這些行。如果條件在WHERE子句中應(yīng)用,在JOIN之后 - 那么我沒有得到我想要的行為。不幸的是:from p in context.Periodsjoin f in context.Facts on p.id equals f.periodid into fgfrom fgi in fg.DefaultIfEmpty()where p.companyid == 100 && fgi.otherid == 17select f.value似乎等同于:SELECT f.valueFROM period as p LEFT OUTER JOIN facts AS f ON p.id = f.periodid WHERE p.companyid = 100 AND f.otherid = 17這不是我想要的。
LINQ to SQL - 具有多個(gè)連接條件的左外連接
RISEBY
2019-08-24 16:50:14