Exemplo n.º 1
0
 public void format_pagination_keeps_existing_order_by()
 {
     var pm=new ParametersManager();
     var page = new Pagination();
     _sut.FormatQueryPagination("order by Id", page, pm)
     .Should().Be("order by Id OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY");
     pm.ToArray().ShouldAllBeEquivalentTo(new[] {page.Skip,page.PageSize});
 }
Exemplo n.º 2
0
 public PagedBuilderResult Build(string sql,object[] args,Pagination page)
 {
     var result=new PagedBuilderResult();
     var provCache = _info.GetSqlCache(_provider.ProviderId);
     var cache = provCache.GetPaged(sql);
     var pm = new ParametersManager(args);
     if (cache == null)
     {
         cache = new PagedSqlCache();
         cache.CountSql = GetCountSql(sql);
         cache.PagedSql = _provider.FormatQueryPagination(sql, page, pm);
         provCache.AddPaged(sql, cache);
     }
     else
     {
         pm.AddValues(page.Skip, page.PageSize);
     }
     result.CountSql = cache.CountSql;
     result.PagedSql = cache.PagedSql;
     result.Args=pm.ToArray();
     return result;
 }
Exemplo n.º 3
0
        public PagedBuilderResult Build(string sql, object[] args, Pagination page)
        {
            var result    = new PagedBuilderResult();
            var provCache = _info.GetSqlCache(_provider.ProviderId);
            var cache     = provCache.GetPaged(sql);
            var pm        = new ParametersManager(args);

            if (cache == null)
            {
                cache          = new PagedSqlCache();
                cache.CountSql = GetCountSql(sql);
                cache.PagedSql = _provider.FormatQueryPagination(sql, page, pm);
                provCache.AddPaged(sql, cache);
            }
            else
            {
                pm.AddValues(page.Skip, page.PageSize);
            }
            result.CountSql = cache.CountSql;
            result.PagedSql = cache.PagedSql;
            result.Args     = pm.ToArray();
            return(result);
        }
Exemplo n.º 4
0
 public override string FormatQueryPagination(string sql, Pagination page, ParametersManager pm)
 {
     if (!sql.Contains("order by")) sql += " order by 1";
     pm.AddValues(page.Skip, page.PageSize);
     return string.Format("{2} OFFSET @{0} ROWS FETCH NEXT @{1} ROWS ONLY",pm.CurrentIndex-2,pm.CurrentIndex-1 ,sql);
 }
Exemplo n.º 5
0
 public override string FormatQueryPagination(string sql, Pagination page, ParametersManager pm)
     => sql + " limit";
Exemplo n.º 6
0
 public override string FormatQueryPagination(string sql, Pagination page, ParametersManager pm) 
     => $"{sql} limit {page.Skip},{page.PageSize}";