protected override Expression VisitMethodCall(MethodCallExpression node) { if (_methodsToExclude.Any(method => QueryableUtility.IsQueryableMethod(node, method))) { return(Visit(node.Arguments[0])); } return(base.VisitMethodCall(node)); }
private IQueryable CreateQuery(Type elementType, System.Linq.Expressions.Expression expression) { Type[] typeArguments = new Type[] { elementType }; IList <IEnumerable <TVal> > subQueries = this._subQueries; if (QueryableUtility.IsQueryableMethod(expression, "Where") || QueryableUtility.IsOrderingMethod(expression)) { subQueries = this.GetSubQueries(expression); } object[] parameters = new object[] { this._queryables, this._equalityComparer, subQueries, expression, this._logger, this._ignoreFailures }; return((IQueryable)typeof(AggregateQuery <>).MakeGenericType(typeArguments).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single <ConstructorInfo>().Invoke(parameters)); }
public TResult Execute <TResult>(Expression expression) { var results = (from queryable in _queryables select TryExecute <TResult>(queryable, expression)).AsQueryable(); if (QueryableUtility.IsQueryableMethod(expression, "Count")) { // HACK: This is in correct since we aren't removing duplicates but count is mostly for paging // so we don't care *that* much return((TResult)(object)results.Cast <int>().Sum()); } return(TryExecute <TResult>(results, expression)); }
private IQueryable CreateQuery(Type elementType, Expression expression) { var queryType = typeof(AggregateQuery <>).MakeGenericType(elementType); var ctor = queryType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance).Single(); var subQueries = _subQueries; // Only update subqueries for ordering and where clauses if (QueryableUtility.IsQueryableMethod(expression, "Where") || QueryableUtility.IsOrderingMethod(expression)) { subQueries = GetSubQueries(expression); } return((IQueryable)ctor.Invoke(new object[] { _queryables, _equalityComparer, subQueries, expression, _logger, _ignoreFailures })); }
protected override Expression VisitMethodCall(MethodCallExpression node) => (!Enumerable.Any <string>(this._methodsToExclude, method => QueryableUtility.IsQueryableMethod(node, method)) ? base.VisitMethodCall(node) : this.Visit(node.Arguments[0]));
public TResult Execute <TResult>(System.Linq.Expressions.Expression expression) { IQueryable <TResult> queryable = (from queryable in this._queryables select((AggregateQuery <TVal>) this).TryExecute <TResult>(queryable, expression)).AsQueryable <TResult>(); return(!QueryableUtility.IsQueryableMethod(expression, "Count") ? this.TryExecute <TResult>(queryable, expression) : ((TResult)queryable.Cast <int>().Sum())); }