The following code has a join on the Users table (wrong) that gives me only the records where AssignedUserId is not null. I need all of the records in Request regardless of the AssignerUserId, and then add the User.Name when the AssignedUserId is not null.
var query = from r in _context.Request
join st in _context.ServiceType on r.ServiceTypeId equals st.ServiceTypeId
join u in _context.Users on r.UserId equals u.UserId
select new RequestDto
{
RequestId = r.RequestId,
UserId = r.UserId,
FirstName = r.FirstName,
//...
ServiceType = st.ServiceName,
AssignedUserId = r.AssignedUserId,
AssignedUser = u.Name
};
return query.ToList();
How do I get the User.Name for only the records where the AssignedUserId is not null?