System.Linq.Dynamic left outer join (IQueryable method)

387 views Asked by At

I have a one problem and i hope you can explain me the solution!

I want to make left outer join between two dynamic classes. I generate two classes at runtime and add its configuration into entityContext:

public DbModelBuilder AddEntityConfiguration<T>(string className, List<ColumnMetadata> columns, DbModelBuilder builder) where T : class 
{
     var configuration = (EntityTypeConfiguration<T>)Activator.CreateInstance(typeof(DynamicViewConfiguration<>).MakeGenericType(typeof(T)), className, columns);
     builder.Configurations.Add(configuration);

    return builder;
}

After this i call GetDynamicQueryResults (use invoke for this):

public IQueryable<T> GetDynamicQueryResults<T>(string className, List<ColumnMetadata> columns, DbModelBuilder builder, ref MainContext context) where T : class
{          
    return context.GetDynamicQueryResults<T>(className);
}

In Vm i write this:

var specificGeneric = typeof (IQueryCatalogDynamic).GetMethod("GetDynamicQueryResults").MakeGenericMethod(dynamicClass.GetType());
var specifications = specificGeneric.Invoke(repository,new object[] { dynamicClass.GetType().Name, _fields, builder, context });

var cfosGeneric = typeof (IQueryCatalogDynamic).GetMethod("GetDynamicQueryResults").MakeGenericMethod(dynamicClass2.GetType());
var cfos = cfosGeneric.Invoke(repository,new object[] {dynamicClass2.GetType().Name, _fields, builder, context});

it works. A want make left outer join between specifications and cfos. I find solution for it: How do I do a left outer join with Dynamic Linq?

but how can i add DefaultIfEmpty() to interface IEnumerableSignatures? now i have exception:

An exception of type 'System.Linq.Dynamic.ParseException' occurred in System.Linq.Dynamic.dll but was not handled in user code

Additional information: No applicable aggregate method 'DefaultIfEmpty' exists

I hope somebody know the solution.

0

There are 0 answers