LINQ Join a statement with a possible NULL identifier?

I have a LINQ statement in which I join the ID field. The problem is that sometimes the identifier to the left of "equal" can be null.
Is there any way to handle this?

+3
source share
1 answer
from x in left
where x.Id != null
join y in right on x.Id equals y.Id into rightMatches
from y2 in rightMatches.DefaultIfEmpty()  //in your comments you said LEFT JOIN
select new {x, y2};
+6
source

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


All Articles