IQueryable IQueryProvider.CreateQuery(Expression expression) { Type elementType = ExpressionTypeSystem.GetElementType(expression.Type); try { return((IQueryable)Activator.CreateInstance(typeof(Query <>).MakeGenericType(elementType), new object[] { this, expression })); } catch (TargetInvocationException tie) { throw tie.InnerException; } }
public override object Execute(Expression expression) { var result = this.Translate(expression); var data = _client.GetData(result.QueryString); if (result.Projector != null) { Type elementType = ExpressionTypeSystem.GetElementType(expression.Type); var projector = result.Projector.Compile(); return(Activator.CreateInstance( typeof(ProjectionReader <,>).MakeGenericType(typeof(T), elementType), BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { data, projector }, null )); } else { return(data); } }