LINQ Join语句可能带有NULL id?

时间:2011-02-25 17:47:44

标签: linq null

我有一个LINQ语句,我正在加入ID字段。问题是有时“等于”左侧的ID可能为空 有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:6)

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};