IsOrderingMethod() публичный статический Метод

public static IsOrderingMethod ( Expression expression ) : bool
expression System.Linq.Expressions.Expression
Результат bool
Пример #1
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));
        }
Пример #2
0
 protected override Expression VisitMethodCall(MethodCallExpression node)
 {
     if (QueryableUtility.IsOrderingMethod(node))
     {
         this._inOrderExpression = true;
         Expression <Func <TElement, IComparable> > operand = (Expression <Func <TElement, IComparable> >)((UnaryExpression)this.Visit(node.Arguments[1])).Operand;
         Ordering <TElement, TElement> item = new Ordering <TElement, TElement>();
         item.Descending = node.Method.Name.EndsWith("Descending", StringComparison.OrdinalIgnoreCase);
         item.Extractor  = operand.Compile();
         this._orderings.Push(item);
         this._inOrderExpression = false;
     }
     return(base.VisitMethodCall(node));
 }
        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 }));
        }
Пример #4
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            if (QueryableUtility.IsOrderingMethod(node))
            {
                _inOrderExpression = true;

                // The lambdas are wrapped in a unary expression
                var unaryExpression = (UnaryExpression)Visit(node.Arguments[1]);
                var lambda          = (Expression <Func <TElement, IComparable> >)unaryExpression.Operand;

                // Push the sort expression on the stack so we can compare later
                _orderings.Push(new Ordering <TElement> {
                    Descending = node.Method.Name.EndsWith("Descending", StringComparison.OrdinalIgnoreCase),
                    Extractor  = lambda.Compile()
                });

                _inOrderExpression = false;
            }
            return(base.VisitMethodCall(node));
        }