public List <dynamic> ToPageList(int pageIndex, int pageSize, out int recordCount) { var sqlBuilder = new SqlServerBuilder(); var sql = sqlBuilder.PagingSelect2008(_table, _fields, _where, _orderBy, pageIndex, pageSize); var command = new SqlCommand(sql); command.Parameters.AddRange(_parameters.Parameters); var param = new SqlParameter("@RecordCount", SqlDbType.Int) { Direction = ParameterDirection.Output }; command.Parameters.Add(param); recordCount = 0; List <dynamic> result; using (var conn = new SqlConnection(_connectionString)) { conn.Open(); command.Connection = conn; using (var sdr = command.ExecuteReader()) { var handler = new SqlDataReaderSelectConverter(); result = handler.ConvertToDynamicList(sdr); } } recordCount = (int)param.Value; return(result); }
public async Task <PagingResult <T> > ToPageListAsync(int pageIndex, int pageSize) { var sqlBuilder = new SqlServerBuilder(); var sql = sqlBuilder.PagingSelect2008(_table, _fields, _where, _orderBy, pageIndex, pageSize); var command = new SqlCommand(sql); command.Parameters.AddRange(_parameters.Parameters); var param = new SqlParameter("@RecordCount", SqlDbType.Int) { Direction = ParameterDirection.Output }; command.Parameters.Add(param); var result = new PagingResult <T>(); using (var conn = new SqlConnection(_connectionString)) { conn.Open(); command.Connection = conn; using (var sdr = await command.ExecuteReaderAsync()) { var handler = new SqlDataReaderSelectConverter(); result.Items = handler.ConvertToList <T>(sdr); } } result.RecordCount = (int)param.Value; return(result); }