Thursday, November 20, 2008

LinQ - left outer join with multi condition

Hi..
I find a post about the problem : http://forums.asp.net/t/1209451.aspx

SELECT a.c1,b.c2,b.c3
FROM t1 a LEFT OUTER JOIN t2 b
ON a.c1=b.c2 AND b.c3='n'



var o = from p in db.t1
join p2 in db.t2 on new { f1 = p.c1, f2 = "n" } equals new { f1 = p2.c2, f2 = p2.c3 } into temp
from x in temp.DefaultIfEmpty()
select new { f1 = p.c1, f2 = x.c2, f3 = x.c3 };

No comments: