开发者

LINQ, Left Join, Only Get where null in join table

I am trying to do a left outer join on two tables, but I only want to return the results from the first table where the second table does not have a record (null).

 var agencies = from a in agencyList
                           join aa in joinTable
                           on a.AgencyId equals aa.AgencyId into joined
                           from aa in joined.DefaultIfEmp开发者_运维知识库ty()
                           where aa == null)
                           select a;

But this does not exclude the non null values of aa, and returns all the records just the same as if the 'where aa == null' was not there.

Any help is appreciated. Thanks.


What about:

var agencies = from a in agencyList
                           where (from aa in joinTable where aa.AgencyId == a.AgencyId select aa).Count() == 0
                           select a;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜