public override void EnterOrderByStmt(SelectSQLParser.OrderByStmtContext context)
        {
            var orderBy = new OrderByCondition();

            var expression = context.columnExpression();

            if (expression == null || expression.IsEmpty)
            {
                throw new MissingOrderByException();
            }

            orderBy.Expression = expression.GetText();

            if (string.IsNullOrEmpty(orderBy.Expression))
            {
                throw new MissingOrderByException();
            }


            orderBy.Direction = OrderByDirection.DESC;

            var direction = context.orderByDirection();

            if (direction == null || direction.IsEmpty)
            {
                orderBy.Direction = OrderByDirection.ASC;
            }
            else if (direction.GetText().Equals("asc", StringComparison.OrdinalIgnoreCase))
            {
                orderBy.Direction = OrderByDirection.ASC;
            }

            this.SelectStmt.OrderBy.Add(orderBy);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="SelectSQLParser.orderByStmt"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitOrderByStmt([NotNull] SelectSQLParser.OrderByStmtContext context)
 {
     return(VisitChildren(context));
 }
Example #3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="SelectSQLParser.orderByStmt"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitOrderByStmt([NotNull] SelectSQLParser.OrderByStmtContext context)
 {
 }