您需要在致电之前介绍您的加入条件
DefaultIfEmpty()。我只会使用扩展方法语法:
from p in context.Periodsjoin f in context.Facts on p.id equals f.periodid into fgfrom fgi in fg.Where(f => f.otherid == 17).DefaultIfEmpty()where p.companyid == 100select f.value
或者您可以使用子查询:
from p in context.Periodsjoin f in context.Facts on p.id equals f.periodid into fgfrom fgi in (from f in fg where f.otherid == 17 select f).DefaultIfEmpty()where p.companyid == 100select f.value



