Esempio n. 1
0
        public bool VisitExprSelectOffsetFetch(ExprSelectOffsetFetch expr, TCtx arg)
        {
            var res = this.Visit(expr, "SelectOffsetFetch", arg, out var argOut) && this.Accept("SelectQuery", expr.SelectQuery, argOut) && this.Accept("OrderBy", expr.OrderBy, argOut);

            this._visitor.EndVisitExpr(expr, arg);
            return(res);
        }
Esempio n. 2
0
 public bool VisitExprSelectOffsetFetch(ExprSelectOffsetFetch exprSelectOffsetFetch, IExpr?parent)
 {
     exprSelectOffsetFetch.SelectQuery.Accept(this, exprSelectOffsetFetch);
     this.Builder.Append(" ORDER BY ");
     exprSelectOffsetFetch.OrderBy.Accept(this, exprSelectOffsetFetch);
     return(true);
 }
Esempio n. 3
0
        public static async Task <DataPage <T> > QueryPage <T>(this ExprSelectOffsetFetch query, ISqDatabase database, Func <ISqDataRecordReader, T> reader)
        {
            var countColumn = CustomColumnFactory.Int32("$count$");

            var selectQuery = (ExprQuerySpecification)query.SelectQuery;

            query = query.WithSelectQuery(
                selectQuery.WithSelectList(selectQuery.SelectList.Concat(SqQueryBuilder.CountOneOver().As(countColumn))));

            var res = await query.Query(database,
                                        new KeyValuePair <List <T>, int?>(new List <T>(), null),
                                        (acc, r) =>
            {
                acc.Key.Add(reader(r));
                var total = acc.Value ?? countColumn.Read(r);
                return(new KeyValuePair <List <T>, int?>(acc.Key, total));
            });

            return(new DataPage <T>(res.Key, query.OrderBy.OffsetFetch.Offset.Value ?? 0, res.Value ?? 0));
        }
Esempio n. 4
0
 public static ExprSelectOffsetFetch WithCrossJoin(this ExprSelectOffsetFetch select, IExprTableSource tableSource)
 => select.SelectQuery is ExprQuerySpecification specification
Esempio n. 5
0
 public static ExprSelectOffsetFetch WithFullJoin(this ExprSelectOffsetFetch select, IExprTableSource tableSource, ExprBoolean on)
 => select.SelectQuery is ExprQuerySpecification specification
Esempio n. 6
0
 public static ExprSelectOffsetFetch WithOrderBy(this ExprSelectOffsetFetch original, ExprOrderByOffsetFetch newOrderBy)
 => new ExprSelectOffsetFetch(selectQuery: original.SelectQuery, orderBy: newOrderBy);
Esempio n. 7
0
 public static ExprSelectOffsetFetch WithSelectQuery(this ExprSelectOffsetFetch original, IExprSubQuery newSelectQuery)
 => new ExprSelectOffsetFetch(selectQuery: newSelectQuery, orderBy: original.OrderBy);
Esempio n. 8
0
 internal ModelRangeRequestData(ExprSelectOffsetFetch expr, Func <ISqDataRecordReader, TRes> mapper)
 {
     this.Expr   = expr;
     this.Mapper = mapper;
 }