public virtual PagedResult <AutoNumber> GetAutoNumbers(string expression, dynamic paraautoNumbers, int pageIndex = 0, int pageSize = 2147483647, IEnumerable <Sort> sort = null) { var searchBuilder = new SqlBuilder(); var search = searchBuilder.AddTemplate(SqlTemplate.AutoNumberSearch(), new { skip = pageIndex * pageSize, take = pageSize }); if (!string.IsNullOrEmpty(expression)) { searchBuilder.Where(expression, paraautoNumbers); } if (sort != null) { foreach (var s in sort) { searchBuilder.OrderBy(s.ToExpression()); } } else { searchBuilder.OrderBy("EntityType"); } var countBuilder = new SqlBuilder(); var count = countBuilder.AddTemplate(SqlTemplate.AutoNumberSearchCount()); if (!string.IsNullOrEmpty(expression)) { countBuilder.Where(expression, paraautoNumbers); } using (var connection = _dapperContext.GetOpenConnection()) { var autoNumbers = connection.Query <AutoNumber>(search.RawSql, search.Parameters); var totalCount = connection.Query <int>(count.RawSql, search.Parameters).Single(); return(new PagedResult <AutoNumber>(autoNumbers, totalCount)); } }