private static Bamboo.Query.Query.OrderByClause GetOrderBy(System.Collections.ArrayList tokens, string from) { System.Collections.ArrayList orderByExpressions = new System.Collections.ArrayList(tokens.Count); foreach (string token in tokens) { if (token.Equals("DESC")) { int index = orderByExpressions.Count - 1; Bamboo.Query.Query.OrderByExpression orderByExpression = (Bamboo.Query.Query.OrderByExpression)orderByExpressions[index]; orderByExpressions.RemoveAt(index); orderByExpressions.Add(new Bamboo.Query.Query.OrderByExpression(orderByExpression.Column, false)); } else if (token.Equals(",")) { } else { orderByExpressions.Add(new Bamboo.Query.Query.OrderByExpression(CreateColumn(token, from))); } } if (orderByExpressions.Count == 0) { return(null); } else { return(new Bamboo.Query.Query.OrderByClause(orderByExpressions)); } }
private static void GenerateOrderBy(SelectStatement query, System.Text.StringBuilder stringBuilder) { if (query.OrderBy == null) { return; } if (query.OrderBy.Expressions.Count == 0) { return; } stringBuilder.Append(" "); stringBuilder.Append("ORDER BY"); stringBuilder.Append(" "); for (int i = 0; i < query.OrderBy.Expressions.Count; i++) { Bamboo.Query.Query.OrderByExpression orderByExpression = (Bamboo.Query.Query.OrderByExpression)query.OrderBy.Expressions[i]; if (i != 0) { stringBuilder.Append(", "); } Escape(stringBuilder, orderByExpression.Column.Identifier); if (!orderByExpression.Ascending) { stringBuilder.Append(" DESC"); } } }
public OrderByNode(Bamboo.Query.Planning.Node node, Bamboo.Query.Query.OrderByClause orderBy) { this._node = node; this._expressions = orderBy.Expressions; System.Collections.ArrayList columns = new System.Collections.ArrayList(this._expressions.Count); this._ascendingOrder = new bool[this._expressions.Count]; for (int i = 0; i < this._expressions.Count; i++) { Bamboo.Query.Query.OrderByExpression orderByExpression = (Bamboo.Query.Query.OrderByExpression) this._expressions[i]; this._ascendingOrder[i] = orderByExpression.Ascending; columns.Add(orderByExpression.Column); } this._indexes = GetIndexes(columns, this._node.ColumnCoordinates); }