In this msdn example:
The .NET Standard Query Operators
We see this example of a LEFT JOIN:
var custTotalOrders =
from c in customers
join o in orders on c.CustomerID equals o.CustomerID into co
from o in co.DefaultIfEmpty(emptyOrder)
select new { c.Name, o.OrderDate, o.Total };
And it says that:
where emptyOrder is an Order instance used to represent a missing order.
So, where does emptyOrder come from?
How can I use it in my code?
There are two overloads for DefaultIfEmpty
DefaultIfEmpty()
DefaultIfEmpty(defaultValue)
The first will return default(T) where T is the type contained in the enumerable when the enumerable is empty.
The second will return the value given in the defaultValue parameter when the enumerable is empty.
Assuming you declared emptyOrder like so:
Then in the query:
When a customer did not have a matching order, the Total property in the projected anonymous object would have the value 100.