Specifies an ordering (OrderBy element)
Inheritance: System.Linq.Expressions.Expression
 public virtual Expression VisitOrdering(OrderingExpression node)
 {
     return base.VisitExtension(node);
 }
Esempio n. 2
0
        public override Expression VisitOrdering(OrderingExpression ordering)
        {
            string value;

            switch ((CqlExpressionType)ordering.NodeType)
            {
                case CqlExpressionType.OrderDescending:
                    value = _translations[ordering.Selector] + " DESC";
                    break;
                case CqlExpressionType.OrderAscending:
                    value = _translations[ordering.Selector] + " ASC";
                    break;
                default:
                    throw new CqlLinqException("Unexpected ordering type encountered: " + ordering.NodeType.ToString());
            }

            _translations[ordering] = value;

            return ordering;
        }
        protected override Expression VisitChildren(ExpressionVisitor visitor)
        {
            bool changed = false;

            var selectClause = (SelectClauseExpression) visitor.Visit(_selectClause);
            changed |= selectClause != _selectClause;

            int count = _whereClause.Count;
            var wheres = new RelationExpression[count];
            for (int i = 0; i < count; i++)
            {
                wheres[i] = (RelationExpression) visitor.Visit(_whereClause[i]);
                changed |= wheres[i] != _whereClause[i];
            }

            count = _orderBy.Count;
            var order = new OrderingExpression[count];
            for (int i = 0; i < count; i++)
            {
                order[i] = (OrderingExpression) visitor.Visit(_orderBy[i]);
                changed |= order[i] != _orderBy[i];
            }

            return changed
                       ? new SelectStatementExpression(_type, selectClause, _tableName, wheres, order, _limit,
                                                       _allowFiltering)
                       : this;
        }