score:0

usually for joins and especially for left joins i use statement syntax.

not tested, but would look something like this:

var result = from a in tablea
             from b in tableb.where(x => x.col1 == a.col1 && x.col2 == a.col2 && a.col3 == 1).defaultifempty()
             select new { a.col1, a.col2, b.col3 };

by doing a .defaultifempty() on the join from tableb, it will treat this as a left join. if you leave out the .defaultifempty() then it will behave like an inner join.

score:0

you can find an extension that facilitates left joins with dynamic linq on github: https://github.com/sikeymael/linqhelper


Related Query