I'm trying to translate following query to lambda expression
var results = (from g in _groups
join cr in _categoryRoots on g.Id equals cr.Group_Id into gcr
from lgc in gcr.DefaultIfEmpty(new CategoryRoot())
join c in _categories on lgc.Id equals c.CategoryRoot_Id into ccr
from lccr in ccr.DefaultIfEmpty()
select new GroupCategory
{
Id = g.Id,
Name = g.Name,
CategoryRoot_Id = lgc == null ? 0: lgc.Id,
CategoryRootName = lgc == null ? "": lgc.Name,
Category_Id = lccr == null ? 0: lccr.Id,
CategoryName = lccr == null ? "": lccr.Name
}).ToList();
Want to change in to something like below.
var rs = _groups.Join(_categoryRoots, g => g.Id, cr => cr.Group_Id, (g, cr) => new GroupCategory { Id = g.Id, Name = g.Name, CategoryRoot_Id = cr.Id, CategoryRootName = cr.Name });
running code example https://dotnetfiddle.net/A3AO0V