I am trying to implement an outer join on this kind of query for the p.Person table.
How would I do this?
This example is taken from http://ashishware.c
If anyone comes across this question and wants an extension method to accomplish this, I created one using the same approach as the other answers. It has the same signature as the regular join extension method.
public static IEnumerable LeftJoin(this IEnumerable outer,
IEnumerable inner, Func outerKeySelector, Func innerKeySelector,
Func resultSelector)
{
return outer
.GroupJoin(inner, outerKeySelector, innerKeySelector, (outerObj, inners) =>
new
{
outerObj,
inners= inners.DefaultIfEmpty()
})
.SelectMany(a => a.inners.Select(innerObj => resultSelector(a.outerObj, innerObj)));
}