since DefaultIfEmpty() is not supported, what is the proper way of doing a left join?
Hard to say how to solve your problem, since you don't say what it is, but generally:
var q = from i in Context.Invoices
select new
{
Number = i.Number,
ItemNumbers = from il in i.Lines
select il.Number
}
LINQ to Entities will coalesce nulls, so you get an empty collection if there are no invoice line items.
Now this produces a graph, rather than a tabular result set. My wild guess is that's what you want, since when you work in LINQ to Entities you generally want to work with objects, rather than tabular SQL results. But like you said, it's hard to be more specific without knowing the precise problem you're trying to solve.
in the end, I used the let way with .FirstOrDefault()
from myothertable
where....
let var = (query).FirstOrDefault()
select new {otherfield, var.field1, var.field2}
Fredou,
I have been searching for how to do a Left Join in L2E for several months now. I thought that it could not be done. Please send me a full query showing how this is done. The last query that you sent did not explain clear enough for me to understand! Thanks!