Skip to content
Advertisement

Entity Framework – Left outer join on multiple columns with OR condition

Is it possible to write lambda left join on multiple columns that would generate OR condition instead of AND?

This will generate following query

I would like to get the same query but instead of AND condition I want it to be OR:

Is there a way to achieve this?

EDIT: version – EF 6.2.0

Advertisement

Answer

LINQ join operators (Join, GroupJoin) support only equi-joins. All other join types have to be implemented as correlated subqueries.

For the join in question you would simply use the alternative LINQ left outer join pattern – correlated SelectMany with DefaultIfEmpty(). Something like this:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement