Ejemplo n.º 1
0
        public bool VisitExprOrderBy(ExprOrderBy expr, TCtx arg)
        {
            var res = this.Visit(expr, "OrderBy", arg, out var argOut) && this.Accept("OrderList", expr.OrderList, argOut);

            this._visitor.EndVisitExpr(expr, arg);
            return(res);
        }
        protected ISelectBuilder OrderByInternal(ExprOrderBy orderBy)
        {
            if (this._orderBy.HasValue)
            {
                throw new SqExpressException("Order has already been set");
            }

            this._orderBy = new OrderByStorage(null, orderBy);
            return(this);
        }
Ejemplo n.º 3
0
        public void AddOrderBy_Basic()
        {
            var tUser     = Tables.User();
            var tCustomer = Tables.Customer();

            var originalExpr = Select(tUser.UserId).From(tUser).Union(Select(tCustomer.UserId).From(tCustomer)).Done();

            var withOrderBy = originalExpr.AddOrderBy(tUser.FirstName);

            var expected = "SELECT [A0].[UserId] FROM [dbo].[user] [A0] UNION SELECT [A1].[UserId] FROM [dbo].[Customer] [A1] ORDER BY [A0].[FirstName]";

            Assert.AreEqual(expected, withOrderBy.ToSql());

            ExprOrderBy orderBy = tUser.FirstName;

            withOrderBy = originalExpr.AddOrderBy(orderBy);

            expected = "SELECT [A0].[UserId] FROM [dbo].[user] [A0] UNION SELECT [A1].[UserId] FROM [dbo].[Customer] [A1] ORDER BY [A0].[FirstName]";
            Assert.AreEqual(expected, withOrderBy.ToSql());
        }
Ejemplo n.º 4
0
 public static ExprSelect WithOrderBy(this ExprSelect original, ExprOrderBy newOrderBy)
 => new ExprSelect(selectQuery: original.SelectQuery, orderBy: newOrderBy);
Ejemplo n.º 5
0
 public static ExprOrderBy WithOrderList(this ExprOrderBy original, IReadOnlyList <ExprOrderByItem> newOrderList)
 => new ExprOrderBy(orderList: newOrderList);
 public ISelectBuilder OrderBy(ExprOrderBy orderBy)
 => this.OrderByInternal(orderBy);
Ejemplo n.º 7
0
 public ISelectBuilder OrderBy(ExprOrderBy orderBy)
 {
     return(this.OrderByInternal(orderBy));
 }
Ejemplo n.º 8
0
 public bool VisitExprOrderBy(ExprOrderBy exprOrderBy, IExpr?parent)
 {
     this.AcceptListComaSeparated(exprOrderBy.OrderList, exprOrderBy);
     return(true);
 }
Ejemplo n.º 9
0
 public static ExprSelect AddOrderBy(this IExprSubQuery original, ExprOrderBy orderBy)
 {
     orderBy.OrderList.AssertNotEmpty("Order item list cannot be empty");
     return(new ExprSelect(original, orderBy));
 }