0

我有两张桌子,地址和人员。人们有 FK 要寻址。我试图找到没有人的地址:

select id from Address a 
left outer join person p on p.address_id = a.id
where p.address_id is null

这可能使用 LINQ to Entities 吗?我尝试了一些变化

 var results = from addr in _context.Addresses
               from ppl in addr.People
               where ppl == null ...

但似乎无法弄清楚如何返回没有人的地址。

4

1 回答 1

0

我提议:

var results = (from addr in _context.Addresses
               where !addr.People.Any()
               select addr).ToList();
于 2012-07-30T20:41:41.863 回答