BrunoLM
BrunoLM

Reputation: 100322

How can I convert this linq expression to method form?

How can I convert this 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);

in Linq with method form.

fake.Join(real, ...)

Is there a tool that could help me to do it?

Upvotes: 1

Views: 110

Answers (1)

David Ly
David Ly

Reputation: 31586

This is what ReSharper converted it into:

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

Upvotes: 1

Related Questions