We are trying to cast an instance of IQueryable<EntityObject> to an IQueryable<SpecificEntityObject>, the SpecificEntityObject type is only known at runtime.
We have tried using the code below, which does not compile because The type or namespace ‘objType’ does not exist.
var t = query.ElementType;
Type objType = typeof(IQueryable<>).MakeGenericType(t);
var typed = query.Cast<IEnumerable<objType>>();
var grouped = typed.GroupByMany(groupBy.Select(grp => grp.Expression).ToArray());
Any ideas?
Use following IQueryable extension generic method
query.ToDTO<sourceType,DestType>();: