我想对两个表进行左外连接,但我只想返回第一个表的结果,而第二个表没有记录(null)。
var agencies = from a in agencyList
join aa in joinTable
on a.AgencyId equals aa.AgencyId into joined
from aa in joined.DefaultIfEmpty()
where aa == null)
select a;
但这并不排除 aa 的非 null 值,并且返回所有记录,就像没有 'where aa == null' 一样。
感谢任何帮助。谢谢。
最佳答案
关于:
var agencies = from a in agencyList
where (from aa in joinTable where aa.AgencyId == a.AgencyId select aa).Count() == 0
select a;
关于c# - LINQ,左连接,仅获取连接表中的空位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2876555/