There are a lot of questions on SO already about Left joins in Linq, and the ones I\'ve looked at all use the join
keyword to achieve the desired end.
T
What are you talking about? That from i in c.Invoice.DefaultIfEmpty()
is exactly a left join.
List strings = new List() { "Foo", "" };
var q = from s in strings
from c in s.DefaultIfEmpty()
select new { s, c };
foreach (var x in q)
{
Console.WriteLine("ValueOfStringIs|{0}| ValueOfCharIs|{1}|",
x.s,
(int)x.c);
}
This test produces:
ValueOfStringIs|Foo| ValueOfCharIs|70|
ValueOfStringIs|Foo| ValueOfCharIs|111|
ValueOfStringIs|Foo| ValueOfCharIs|111|
ValueOfStringIs|| ValueOfCharIs|0|