【问题标题】:EF4.1 and Left Outer Join to find nulls?EF4.1 和左外连接查找空值?
【发布时间】:2012-07-30 19:43:26
【问题描述】:

我有两张表,地址和人员。人们有 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 ...

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

【问题讨论】:

    标签: entity-framework-4.1 outer-join


    【解决方案1】:

    我建议:

    var results = (from addr in _context.Addresses
                   where !addr.People.Any()
                   select addr).ToList();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 2015-03-20
      • 2014-10-12
      • 1970-01-01
      • 2012-06-14
      相关资源
      最近更新 更多