I have the following SQL query that has left join with tow parameters
select val1,val2 from tbl1
left join tbl2 on (tbl1.ID = tbl2.ForKey1 or tbl1.id= tbl2.ForKey2)
What is the equivalent Linq query to it that retrieve the same result ?
I have the following SQL query that has left join with tow parameters
select val1,val2 from tbl1
left join tbl2 on (tbl1.ID = tbl2.ForKey1 or tbl1.id= tbl2.ForKey2)
What is the equivalent Linq query to it that retrieve the same result ?
You can use documented Collection selector references outer in a non-where case
var query =
from tbl1 in ctx.tbl1
from tbl2 in ctx.tbl2
.Where(tb2 => tbl1.ID == tbl2.ForKey1 || tbl1.id == tbl2.ForKey2)
.DefaultIfEmpty()
select new
{
tbl1,
tbl2
};