IsQueryableMethod() 공개 정적인 메소드

public static IsQueryableMethod ( Expression expression, string method ) : bool
expression System.Linq.Expressions.Expression
method string
리턴 bool
예제 #1
0
 protected override Expression VisitMethodCall(MethodCallExpression node)
 {
     if (_methodsToExclude.Any(method => QueryableUtility.IsQueryableMethod(node, method)))
     {
         return(Visit(node.Arguments[0]));
     }
     return(base.VisitMethodCall(node));
 }
예제 #2
0
        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 }));
        }
예제 #5
0
 protected override Expression VisitMethodCall(MethodCallExpression node) =>
 (!Enumerable.Any <string>(this._methodsToExclude, method => QueryableUtility.IsQueryableMethod(node, method)) ? base.VisitMethodCall(node) : this.Visit(node.Arguments[0]));
예제 #6
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()));
        }