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, … Read more

System.LINQ.Dynamic: Select(” new (…)”) into a List (or any other enumerable collection of )

First, you’ll access the current grouped value as Key in your Select clause: .Select(“new (Key as Group, Sum(Value) as TotalValue)”); That should make your query work. The harder question is how to turn the returned objects, which will have a dynamically generated type that inherits from DynamicClass, into a static type. Option 1: Use reflection … Read more

LINQ : Dynamic select

You can do this by dynamically creating the lambda you pass to Select: Func<Data,Data> CreateNewStatement( string fields ) { // input parameter “o” var xParameter = Expression.Parameter( typeof( Data ), “o” ); // new statement “new Data()” var xNew = Expression.New( typeof( Data ) ); // create initializers var bindings = fields.Split( ‘,’ ).Select( o … Read more