joining tables on two columns is easy
from t1 in table1
join t2 in table2
on new { KEY1 = t1.TB1Key1, KEY2 = t1.TB1Key2 }
equals new { KEY1 = t2.TB2Key1, KEY2 = t2.TB2Key2 }
select new { t1 , t2}
but what if i want an OR condition? the SQL will look something like this:
select * from table1 t1
inner join table2 t2
on t1.TB1Key1 = t2.TB2Key1 OR t1.TB1Key2= t2.TB2Key2
but couldn't find a way to do it in EF,
in my case t2.TB1Key should be equal to t1.TB1Key1 OR t1.TB1Key2 if t1.TB1Key1 is null
so solved it like this:
from t1 in table1
join t2 in table2
on new { KEY = t1.TB1Key1 ?? t1.TB1Key2 }
equals new { KEY = t2.TB2Key}
select new { t1 , t2}
but still would like to know if it is possible to use OR in the join condition