EF Core Linq to SQL how to rewrite with innerJoin into Lambda expression
I got this older linq to sql expression
var users=
(
(from e in this.dbContext.Users
join t in this.dbContext.Titles
on e.UserId equals t.UserId
into et
join d in this.dbContext.Dept
on e.DeptId equals d.DeptId
from et_left in et.DefaultIfEmpty()
select new UserViewModel
{
UserId = UserId
EntryDate=e.EntryDate,
Extension = et_left.Extension,
})).ToList();
This expression works and returns 19601 records
I am trying to rewrite into lambda expression but its returning 13508. I am getting comfortable with Lambda but I read on a few posts that .Join performs the inner join but I am bit lost on this.
var users= this.dbContext.Users
.Join(this.dbContext.Titles
user => user.UserId,
title => title.UserId,
(user, title) => new {user, title}
)
.Join(this.dbContext.Dept,
user_title => user_title.DeptId,
dept => dept.DeptId,
(user_title, dept ) => new {user_title, dept }
)
select new UserViewModel
{
UserId = joined.user_title.user.UserId,
DeptId = joined.user_title.user.DeptId,
EntryDate= joined.user_title.user.EntryDate,
Extension = joined.user_title.user.Extension,
...
})).ToList();