How to achieve Left Excluding JOIN using LINQ?

后端 未结 3 807
南方客
南方客 2021-01-17 08:04

How to achieve Left Excluding JOIN using LINQ?

In SQL:

SELECT  
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
WHERE B.Key I         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 08:13

    You need DefaultIfEmpty() for the LEFT JOIN, then you can check if the joined value is null:

    var result = from a in Table_A
                 join b in Table_B on a.Key equals b.Key into j
                 from b in j.DefaultIfEmpty()
                 where b == null
                 select new { ... };
    

提交回复
热议问题