c# - LEFT OUTER JOIN in LINQ -
how perform left outer join in c# linq objects without using join-on-equals-into clauses? there way where clause? correct problem: inner join easy , have solution this
list<joinpair> innerfinal = (from l in lefts r in rights l.key == r.key select new joinpair { leftid = l.id, rightid = r.id}) but left outer join need solution. mine it's not working
list< joinpair> leftfinal = (from l in lefts r in rights select new joinpair { leftid = l.id, rightid = ((l.key==r.key) ? r.id : 0 }) where joinpair class:
public class joinpair { long leftid; long rightid; }
as stated on:
101 linq samples - left outer join
var q = c in categories join p in products on c.category equals p.category ps p in ps.defaultifempty() select new { category = c, productname = p == null ? "(no products)" : p.productname };
Comments
Post a Comment