如何转换此linq
from f in fake
join r in real
on f.Year equals r.Year
into joinResult
from r in joinResult.DefaultIfEmpty()
select (r == null ? f : r);
在Linq中使用方法表单。
fake.Join(real, ...)
是否有工具可以帮助我做到这一点?
答案 0 :(得分:1)
这就是ReSharper将其转换为:
fake.GroupJoin(real, f => f.Year, r => r.Year, (f, joinResult) => new {f, joinResult})
.SelectMany(@t => @t.joinResult.DefaultIfEmpty(), (@t, r) => (r == null ? @t.f : r));