Ejemplo n.º 1
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)
            {
                MySqlOrderByClauseVisitor visitor = new MySqlOrderByClauseVisitor(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);
        }
Ejemplo 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)
            {
                MySqlOrderByPartsCommandBuilder orderBuilder = new MySqlOrderByPartsCommandBuilder();

                MySqlOrderByClauseVisitor visitor = new MySqlOrderByClauseVisitor();

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