简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM