public virtual void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
        {
            ArgumentUtility.CheckNotNull ("orderByClause", orderByClause);
              ArgumentUtility.CheckNotNull ("queryModel", queryModel);

              VisitOrderings (orderByClause.Orderings, queryModel, orderByClause);
        }
 public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
 {
     foreach (var ordering in orderByClause.Orderings)
     {
         model.AddSort(ordering.Expression, ordering.OrderingDirection);
     }
 }
Пример #3
0
    /// <summary>
    /// Accepts the specified visitor by calling its <see cref="IQueryModelVisitor.VisitOrdering"/> method.
    /// </summary>
    /// <param name="visitor">The visitor to accept.</param>
    /// <param name="queryModel">The query model in whose context this clause is visited.</param>
    /// <param name="orderByClause">The <see cref="OrderByClause"/> in whose context this item is visited.</param>
    /// <param name="index">The index of this item in the <paramref name="orderByClause"/>'s <see cref="OrderByClause.Orderings"/> collection.</param>
    public virtual void Accept (IQueryModelVisitor visitor, QueryModel queryModel, OrderByClause orderByClause, int index)
    {
      ArgumentUtility.CheckNotNull ("visitor", visitor);
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);
      ArgumentUtility.CheckNotNull ("orderByClause", orderByClause);

      visitor.VisitOrdering (this, queryModel, orderByClause, index);
    }
Пример #4
0
 public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
 {
     var joinDetector = new SelectAndOrderByJoinDetector(_nameGenerator, this, _joins, _expressionMap);
     foreach (Ordering ordering in orderByClause.Orderings)
     {
         joinDetector.VisitExpression(ordering.Expression);
     }
 }
    protected override void ApplyNodeSpecificSemantics (QueryModel queryModel, ClauseGenerationContext clauseGenerationContext)
    {
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      var clause = new OrderByClause();
      clause.Orderings.Add (new Ordering (GetResolvedKeySelector (clauseGenerationContext), OrderingDirection.Desc));
      queryModel.BodyClauses.Add (clause);
    }
Пример #6
0
        public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
        {
            var visitor = new EnigmaExpressionTreeVisitor(_objectExpression);
            foreach (var ordering in orderByClause.Orderings) {
                visitor.VisitExpression(ordering.Expression);
                _objectExpression.OrderBy(ordering.OrderingDirection);
            }

            base.VisitOrderByClause(orderByClause, queryModel, index);
        }
        public void ConvertsToSort_Desc()
        {
            var orderByClause = new OrderByClause();
            orderByClause.Orderings.Add(new Ordering(new LuceneQueryFieldExpression(typeof(string), "Name"), OrderingDirection.Desc));
            ExpectSortOnProperty("Name", SortField.STRING, OrderingDirection.Desc);

            transformer.VisitOrderByClause(orderByClause, queryModel, 0);

            Assert.That(transformer.Model.Sort.GetSort().Length, Is.EqualTo(1));
            AssertSortFieldEquals(transformer.Model.Sort.GetSort()[0], "Name", OrderingDirection.Desc, SortField.STRING);
        }
        public void ConvertsDateTimeOffsetToSort()
        {
            var orderByClause = new OrderByClause();
            orderByClause.Orderings.Add(new Ordering(new LuceneQueryFieldExpression(typeof(DateTimeOffset?), "Date"), OrderingDirection.Asc));
            ExpectSortOnProperty("Date", SortField.LONG, OrderingDirection.Asc);

            transformer.VisitOrderByClause(orderByClause, queryModel, 0);

            Assert.That(transformer.Model.Sort.GetSort().Length, Is.EqualTo(1));
            AssertSortFieldEquals(transformer.Model.Sort.GetSort()[0], "Date", OrderingDirection.Asc, SortField.LONG);
        }
        public void ConvertsDateTimeToSortNonNumeric()
        {
            var orderByClause = new OrderByClause();
            orderByClause.Orderings.Add(new Ordering(new LuceneQueryFieldExpression(typeof(DateTimeOffset?), "Date"), OrderingDirection.Asc));
            mappingInfo.Expect(m => m.GetMappingInfo("Date")).Return(nonNumericMappingInfo);
            nonNumericMappingInfo.Stub(i => i.FieldName).Return("Date");

            transformer.VisitOrderByClause(orderByClause, queryModel, 0);

            Assert.That(transformer.Model.Sort.GetSort().Length, Is.EqualTo(1));
            AssertSortFieldEquals(transformer.Model.Sort.GetSort()[0], "Date", OrderingDirection.Asc, SortField.STRING);
        }
Пример #10
0
        public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
        {
            foreach (var clause in orderByClause.Orderings)
            {
                var orderBy   = HqlGeneratorExpressionVisitor.Visit(clause.Expression, VisitorParameters).ToArithmeticExpression();
                var direction = clause.OrderingDirection == OrderingDirection.Asc
                                        ? _hqlTree.TreeBuilder.Ascending()
                                        : (HqlDirectionStatement)_hqlTree.TreeBuilder.Descending();

                _hqlTree.AddOrderByClause(orderBy, direction);
            }
        }
    public void Apply ()
    {
      var clause = new OrderByClause ();
      QueryModel.BodyClauses.Add (clause);

      var result = _node.Apply (QueryModel, ClauseGenerationContext);
      Assert.That (result, Is.SameAs (QueryModel));

      Assert.That (clause.Orderings.Count, Is.EqualTo (1));
      Assert.That (clause.Orderings[0].OrderingDirection, Is.EqualTo (OrderingDirection.Asc));
      Assert.That (clause.Orderings[0].Expression, Is.SameAs (_node.GetResolvedKeySelector (ClauseGenerationContext)));
    }
        public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
        {
            Log.Trace(m => m("Original QueryModel:     {0}", queryModel));

            foreach (var visitor in orderingVisitors)
            {
                orderByClause.TransformExpressions(visitor.VisitExpression);
                Log.Trace(m => m("Transformed QueryModel after {0}: {1}", visitor.GetType().Name, queryModel));
            }
            
            ExpandCompositeOrderings(orderByClause);

            base.VisitOrderByClause(orderByClause, queryModel, index);
        }
Пример #13
0
        /// <summary>
        /// 解析 orderby 语句
        /// </summary>
        /// <param name="orderByClause"></param>
        /// <param name="queryModel"></param>
        /// <param name="index"></param>
        public override void VisitOrderByClause( OrderByClause orderByClause, QueryModel queryModel, int index )
        {
            foreach( var ordering in orderByClause.Orderings )
            {
                MySqlOrderByClauseVisitor visitor = new MySqlOrderByClauseVisitor( this.parameterAggregator );

                string orderByParts = visitor.Translate( ordering.Expression );

                string direction = ordering.OrderingDirection == OrderingDirection.Desc ? "DESC" : "ASC";

                queryPartsAggregator.OrderByParts.Add( string.Format( "{0} {1}", orderByParts, direction ) );
            }

            base.VisitOrderByClause( orderByClause, queryModel, index );
        }
    public void SetUp ()
    {
      _generator = new UniqueIdentifierGenerator();
      _context = SqlStatementModelObjectMother.CreateSqlPreparationContext();
      _defaultStage = new DefaultSqlPreparationStage (
          CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), _generator);

      _mainFromClause = ExpressionHelper.CreateMainFromClause<Cook>();
      _selectClause = ExpressionHelper.CreateSelectClause (_mainFromClause);
      _orderByClause = ExpressionHelper.CreateOrderByClause();
      _queryModel = new QueryModel (_mainFromClause, _selectClause);

      _stageMock = MockRepository.GenerateStrictMock<ISqlPreparationStage>();
      _visitor = new TestableSqlPreparationQueryModelVisitor (_context, _stageMock);
      _visitorPartialMock = MockRepository.GeneratePartialMock<TestableSqlPreparationQueryModelVisitor> (_context, _stageMock);
    }
Пример #15
0
        /// <summary>
        /// 解析 orderby 语句
        /// </summary>
        /// <param name="orderByClause"></param>
        /// <param name="queryModel"></param>
        /// <param name="index"></param>
        public override void VisitOrderByClause( OrderByClause orderByClause, QueryModel queryModel, int index )
        {
            foreach( var ordering in orderByClause.Orderings )
            {
                OracleOrderByPartsCommandBuilder orderBuilder = new OracleOrderByPartsCommandBuilder();

                OracleOrderByClauseVisitor visitor = new OracleOrderByClauseVisitor();

                visitor.Translate( ordering.Expression, orderBuilder );

                string direction = ordering.OrderingDirection == OrderingDirection.Desc ? "desc" : "asc";

                commandBuilder.OrderByParts.Add( string.Format( "{0} {1}", orderBuilder.ToString(), direction ) );
            }

            base.VisitOrderByClause( orderByClause, queryModel, index );
        }
    public void SetUp ()
    {
      _mockRepository = new MockRepository();
      _visitorMock = _mockRepository.StrictMock<TestQueryModelVisitor>();

      _bodyClauseMock1 = _mockRepository.StrictMock<IBodyClause>();
      _bodyClauseMock2 = _mockRepository.StrictMock<IBodyClause>();

      _ordering1 = new Ordering (ExpressionHelper.CreateExpression(), OrderingDirection.Asc);
      _ordering2 = new Ordering (ExpressionHelper.CreateExpression(), OrderingDirection.Asc);

      _resultOperator1 = new TestResultOperator();
      _resultOperator2 = new TestResultOperator();

      _queryModel = ExpressionHelper.CreateQueryModel<Cook>();
      _orderByClause = ExpressionHelper.CreateOrderByClause();
      _groupJoinClause = ExpressionHelper.CreateGroupJoinClause<Cook>();
    }
Пример #17
0
    public void SetUp ()
    {
      _mockRepository = new MockRepository();
      _visitorMock = _mockRepository.StrictMock<QueryModelVisitorBase>();
      _testVisitor = new TestQueryModelVisitor ();

      _bodyClauseMock1 = _mockRepository.StrictMock<WhereClause> (ExpressionHelper.CreateExpression());
      _bodyClauseMock2 = _mockRepository.StrictMock<WhereClause> (ExpressionHelper.CreateExpression());

      _orderingMock1 = _mockRepository.StrictMock<Ordering> (ExpressionHelper.CreateExpression(), OrderingDirection.Asc);
      _orderingMock2 = _mockRepository.StrictMock<Ordering> (ExpressionHelper.CreateExpression(), OrderingDirection.Asc);

      _resultOperatorMock1 = _mockRepository.StrictMock<ResultOperatorBase> ();
      _resultOperatorMock2 = _mockRepository.StrictMock<ResultOperatorBase> ();

      _queryModel = ExpressionHelper.CreateQueryModel<Cook> ();
      _orderByClause = ExpressionHelper.CreateOrderByClause ();
      _groupJoinClause = ExpressionHelper.CreateGroupJoinClause<Cook> ();
    }
Пример #18
0
        public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index)
        {
            if (_query.OrderByPredicate == null)
            {
                _query.OrderByPredicate = ODataQueryPart.OrderBy();
            }

            if (ordering.Expression.NodeType == ExpressionType.MemberAccess)
            {
                var memberExpression = (MemberExpression)ordering.Expression;

                var direction = (ordering.OrderingDirection == OrderingDirection.Asc)
                    ? ODataOrderingDirection.Asc
                    : ODataOrderingDirection.Desc;

                var o = ODataQueryPart.Ordering(memberExpression.Member.Name, direction);

                _query.OrderByPredicate.AddOrdering(o);
            }

            base.VisitOrdering(ordering, queryModel, orderByClause, index);
        }
Пример #19
0
 public void AddOrderBy(OrderByClause orderBy)
 {
     OrderBy.Add(orderBy);
 }
		public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
		{
			QueryParts.AddOrderBy(orderByClause);

			base.VisitOrderByClause(orderByClause, queryModel, index);
		}
		public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index)
		{
			_resultOperatorAndOrderByJoinDetector.Transform(ordering);
		}
 public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
 {
     base.VisitOrderByClause(orderByClause, queryModel, index);
 }
        public virtual void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index)
        {
            ArgumentUtility.CheckNotNull ("ordering", ordering);
              ArgumentUtility.CheckNotNull ("queryModel", queryModel);
              ArgumentUtility.CheckNotNull ("orderByClause", orderByClause);

              // nothing to do here
        }
Пример #24
0
        /// <summary>
        /// Accepts the specified visitor by calling its <see cref="IQueryModelVisitor.VisitOrdering"/> method.
        /// </summary>
        /// <param name="visitor">The visitor to accept.</param>
        /// <param name="queryModel">The query model in whose context this clause is visited.</param>
        /// <param name="orderByClause">The <see cref="OrderByClause"/> in whose context this item is visited.</param>
        /// <param name="index">The index of this item in the <paramref name="orderByClause"/>'s <see cref="OrderByClause.Orderings"/> collection.</param>
        public virtual void Accept(IQueryModelVisitor visitor, QueryModel queryModel, OrderByClause orderByClause, int index)
        {
            ArgumentUtility.CheckNotNull("visitor", visitor);
            ArgumentUtility.CheckNotNull("queryModel", queryModel);
            ArgumentUtility.CheckNotNull("orderByClause", orderByClause);

            visitor.VisitOrdering(this, queryModel, orderByClause, index);
        }
        protected virtual void VisitOrderings(ObservableCollection<Ordering> orderings, QueryModel queryModel, OrderByClause orderByClause)
        {
            ArgumentUtility.CheckNotNull ("queryModel", queryModel);
              ArgumentUtility.CheckNotNull ("orderByClause", orderByClause);
              ArgumentUtility.CheckNotNull ("orderings", orderings);

              foreach (var indexValuePair in orderings.AsChangeResistantEnumerableWithIndex())
            indexValuePair.Value.Accept (this, queryModel, orderByClause, indexValuePair.Index);
        }
Пример #26
0
 /// <summary>
 /// Doing ordering of the clause, are we?
 /// </summary>
 /// <param name="orderByClause"></param>
 /// <param name="queryModel"></param>
 /// <param name="index"></param>
 public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
 {
     base.VisitOrderByClause(orderByClause, queryModel, index);
     foreach (var expr in orderByClause.Orderings.Select(o => o.Expression))
     {
         _exprVisitor.Visit(expr);
     }
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index)
     => ordering.TransformExpressions(TransformingVisitor.Visit);
Пример #28
0
		public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
		{
			foreach (var clause in orderByClause.Orderings)
			{
				_hqlTree.AddOrderByClause(HqlGeneratorExpressionTreeVisitor.Visit(clause.Expression, VisitorParameters).AsExpression(),
								clause.OrderingDirection == OrderingDirection.Asc
									? _hqlTree.TreeBuilder.Ascending()
									: (HqlDirectionStatement)_hqlTree.TreeBuilder.Descending());
			}
		}
        public override void VisitOrderByClause( OrderByClause orderByClause, QueryModel queryModel, int index )
        {
            var expression = orderByClause.Orderings[0].Expression as MemberExpression;
            if( expression == null )
                return;

            OrderBy reql;
            var currentStack = Stack.Pop();
            if( orderByClause.Orderings[0].OrderingDirection == OrderingDirection.Asc )
                reql = currentStack.OrderBy( expression.Member.Name );
            else
                reql = currentStack.OrderBy( RethinkDB.R.Desc( expression.Member.Name ) );

            if( currentStack is Table && expression.Member.CustomAttributes.Any( x => x.AttributeType == typeof( PrimaryIndexAttribute ) || x.AttributeType == typeof( SecondaryIndexAttribute ) ) )
                reql = reql.OptArg( "index", expression.Member.Name );

            Stack.Push( reql );
        }
        protected override void VisitOrderings(ObservableCollection<Ordering> orderings, QueryModel queryModel, OrderByClause orderByClause)
        {
            var orders = orderings.SelectMany(ordering => PropertyPathExtractionVisitor.ExtractPaths(ordering.Expression, _nodeTypeProvider, false, true, _namingScheme, ".")
                .Select(path => string.Format("{0} {1}", path, ordering.OrderingDirection.ToString().ToLowerInvariant())))
                .ToList();
            if (orders.Count > 0)
            {
                if (OrderBy != null)
                {
                    OrderBy = "," + OrderBy;
                }
                OrderBy = string.Join(",", orders.ToArray()) + OrderBy;
            }

            base.VisitOrderings(orderings, queryModel, orderByClause);
        }
Пример #31
0
 /// <summary>
 /// Accepts the specified visitor by calling its <see cref="IQueryModelVisitor.VisitOrdering"/> method.
 /// </summary>
 /// <param name="visitor">The visitor to accept.</param>
 /// <param name="queryModel">The query model in whose context this clause is visited.</param>
 /// <param name="orderByClause">The <see cref="OrderByClause"/> in whose context this item is visited.</param>
 /// <param name="index">The index of this item in the <paramref name="orderByClause"/>'s <see cref="OrderByClause.Orderings"/> collection.</param>
 public virtual void Accept(IQueryModelVisitor visitor, QueryModel queryModel, OrderByClause orderByClause, int index)
 {
     visitor.VisitOrdering(this, queryModel, orderByClause, index);
 }
        public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
        {
            var orderByParts =
                orderByClause.Orderings.Select(
                    ordering =>
                        String.Concat(GetN1QlExpression(ordering.Expression), " ",
                            ordering.OrderingDirection.ToString().ToUpper())).ToList();

            _queryPartsAggregator.AddOrderByPart(orderByParts);

            base.VisitOrderByClause(orderByClause, queryModel, index);
        }
    public void Apply_UsesLastClause ()
    {
      var clause = new OrderByClause ();
      QueryModel.BodyClauses.Add (new OrderByClause ());
      QueryModel.BodyClauses.Add (clause);

      _node.Apply (QueryModel, ClauseGenerationContext);

      Assert.That (clause.Orderings.Count, Is.EqualTo (1));
    }