我试过
db.Table1.GroupJoin(db.Table2,
t1 => t1.Id,
t2 => t2.t1Id,
(t1,g) => new { t1, g })
.Where(item => !item.g.Any())
.Select(item => item.t1);
但它返回了 0 个结果。我正在尝试编写一些生成以下 SQL 代码(或类似代码)的东西
SELECT t1.*
FROM Table1 as t1
LEFT OUTER JOIN Table2 as t2
ON t1.Id = t2.t1Id
WHERE IsNull(t2.Id);