How do I do a left outer join with Dynamic Linq?

Add void DefaultIfEmpty(); to interface IEnumerableSignatures

Then use

public static object DefaultIfEmpty(this IQueryable source)
{
    if (source == null) throw new ArgumentNullException("source");
        return source.Provider.Execute(
    Expression.Call(
        typeof(Queryable), "DefaultIfEmpty",
        new Type[] { source.ElementType },
        source.Expression));
}

Then you have a call like

var qry = Foo.GroupJoin(Bar, "outer.Id", "inner.Id", "new(outer.Id as Foo, group as Bars)").SelectMany("Bars.DefaultIfEmpty()", "new(outer.Foo as Foo, inner as Bar)");

Leave a Comment