public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
        {
            _queryParts.AddOrderByPart(orderByClause.Orderings.Select(o =>
                                                                      new Tuple <string, OrderingDirection>(GetPsqlExpression(o.Expression), o.OrderingDirection)));

            base.VisitOrderByClause(orderByClause, queryModel, index);
        }
예제 #2
0
        /// Adds an ORDER BY part of the SQL query.
        ///
        /// If a subquery parts aggregator is open, redirects the call to it instead.
        public void AddOrderByPart(IEnumerable <Tuple <string, OrderingDirection> > orderings)
        {
            if (_visitingSubQueryExpression)
            {
                _subQueryExpressionPartsAggregator.AddOrderByPart(orderings);
            }
            else
            {
                List <string> localOrderByParts = new List <string>();

                foreach (var ordering in orderings)
                {
                    string orderByPart =
                        (ordering.Item2 == OrderingDirection.Desc) ?
                        ordering.Item1 + " DESC" :
                        ordering.Item1;

                    localOrderByParts.Add(orderByPart);
                }

                localOrderByParts.AddRange(OrderByParts);
                OrderByParts = localOrderByParts;
            }
        }