LEFT OUTER JOIN in LINQ

后端 未结 22 2452
臣服心动
臣服心动 2020-11-21 04:49

How to perform left outer join in C# LINQ to objects without using join-on-equals-into clauses? Is there any way to do that with where clause? Corr

22条回答
  •  执念已碎
    2020-11-21 05:25

    As stated on:

    101 LINQ Samples - Left outer join

    var q =
        from c in categories
        join p in products on c.Category equals p.Category into ps
        from p in ps.DefaultIfEmpty()
        select new { Category = c, ProductName = p == null ? "(No products)" : p.ProductName };
    

提交回复
热议问题