public SqlStringBuilder Append(FormattableString data) { var s = data.Format; for (var i = 0; i < data.ArgumentCount; i++) { s = s.Replace("{" + i + "}", "@" + _pm.CurrentIndex); _pm.AddValues(data.GetArgument(i)); } _sql.Append(s); return(this); }
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; }
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); }
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); }