LINQ Join Multiple Fields

What would be equivalent to the following T-SQL query in L2E using Lambda expressions?

Select * from a INNER JOIN b on a.Foo = b.Foo OR a.Foo = b.Bar 

I want to join a and b when a.Foo is equal to b.Foo OR b.Bar

Thanks.

+4
source share
1 answer

You cannot execute the "or" style in LINQ with the actual join clause. All join offers in LINQ are equijoins. The closest you can find is the where clause:

 var query = from a in A from b in B where a.Foo == b.Foo || a.Foo == b.Bar select new { a, b }; 
+7
source

Source: https://habr.com/ru/post/1386340/


All Articles