コード例 #1
0
		protected virtual OrderByClause VisitOrderBy(OrderByClause orderBy)
		{
			if (orderBy == null)
				return null;

			var secondary = this.VisitOrderBy(orderBy.SecondarySortingClause);
			var flag = secondary != orderBy.SecondarySortingClause;

			var newOrderBy = new OrderByClause(secondary);
			foreach (var col in orderBy.SortColumns)
			{
				var newCol = this.Visit(col.Item1);
				newOrderBy.AppendColumn(Tuple.Create(newCol, col.Item2));

				if (newCol != col.Item1)
					flag = true;
			}

			if (flag)
				return newOrderBy;
			return orderBy;
		}
コード例 #2
0
		private OrderByClause BuildNestedOrderBy(SelectExpression select, OrderByClause orderBy)
		{
			if (orderBy == null)
				return null;

			var newOrderBy = new OrderByClause(BuildNestedOrderBy(select, orderBy.SecondarySortingClause));
			var columns = orderBy.SortColumns;
			var unmatchedColumns = new List<Expression>();
			foreach (var col in columns)
			{
				Expression expr = select.TryFindColumn(col.Item1);
				if (expr == null)
					expr = select.AddUnmappedColumn(col.Item1);
				newOrderBy.AppendColumn(Tuple.Create(expr, col.Item2));
			}
			return newOrderBy;
		}