1

My question is mostly similar to this question LINQ Join with Multiple Conditions in On Clause and most other similar question which either talk about having properties to specifically map the respective conditions or writing a query without join like

from t1 in Projects
from t2 in Tasks.Where(x => t1.ProjectID == x.ProjectID && x.Completed == true)
                .DefaultIfEmpty()
select new { t1.ProjectName, t2.TaskName }

Suppose if I go for the first way of writing i.e.

on new { t1.ProjectID, SecondProperty = true } equals 
   new { t2.ProjectID, SecondProperty = t2.Completed } into j1

that gets converted to AND (&&). I want an OR (||) in the join form (2nd way of writing).

Thanks in advance.

Hussain Mir
  • 107
  • 7

1 Answers1

1

If you want to perform the join by the ProjectID and then have an || on the SecondProperty then you must join by one field and add a where clause:

from t1 in Projects
join t2 in Tasks on t1.ProjectID equals t2.ProjectID
where t1.SecondProperty || t1.SecondProperty == t2.Completed
select new { t1, t2 }
Gilad Green
  • 36,708
  • 7
  • 61
  • 95