You have an internal connection, while you need a left connection.
correct the linq query as follows:
join status in db.RetailStatus on order.StatusId equals status.Id into rs from status in rs.DefaultIfEmpty() join customer in db.RetailCustomers on order.RetailCustomerId equals customer.Id into rc from customer in rc.DefaultIfEmpty()
In this case, the Select will be the same, except for the need to handle the null situation in the left table, I would do it like this:
Status = rs?.Status ?? string.Empty
In this example, I used the innovations of version 6 of the c # language ?. - the so-called elvis operator
Types of connections in SQL
You can also use the navigation properties to get related entities, then the query will look like this:
from o in Orders select new { Status = o.Status?.Name ?? string.Empty }
The way to create a navigation property depends on the linq provider used. For example, when using the EF code first approach, the declaration of the navigation properties looks like this:
public class Order { public int Id {get;set;} public int OrderStatusId {get;set;} //Навигационное свойство public virtual OrderStatus Status {get;set;} } public class OrderStatus { public int Id {get;set;} public string Name {get;set;} }
more on getting related entities using EF
joinand you needleft join- Bald