/// <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)
            {
                SqlServerOrderByClauseVisitor visitor = new SqlServerOrderByClauseVisitor(this.parameters);

                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);
        }
Esempio n. 2
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)
            {
                SqlServerOrderByPartsCommandBuilder orderBuilder = new SqlServerOrderByPartsCommandBuilder();

                SqlServerOrderByClauseVisitor visitor = new SqlServerOrderByClauseVisitor();

                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);
        }