public async Task <TrainPaging> GetAll(int skip, int limit, string filter) { using (var conn = new SqlConnection(AppSettings.ConnectionString)) { string sqlfilter, sql; CreateFilter(filter, out sqlfilter, out sql); var result = (await conn.QueryAsync <TrainExt, Stantion, TrainExt>( sql, (train, stantion) => { train.Stantion = stantion; return(train); }, new { skip = skip, limit = limit })).ToArray(); foreach (var item in result) { item.CanDelete = true; } var sqlc = $"{TrainCommon.sqlCountCommon} {sqlfilter}"; var count = conn.ExecuteScalar <int>(sqlc); var output = new TrainPaging { Data = result, Total = count }; return(output); } }
public async Task <TrainPaging> GetAll(int skip, int limit) { using (var conn = new SqlConnection(AppSettings.ConnectionString)) { var sql = Sql.SqlQueryCach["Train.All"]; var result = (await conn.QueryAsync <TrainExt, Stantion, TrainExt>( sql, (train, stantion) => { train.Stantion = stantion; return(train); }, new { skip = skip, limit = limit })).ToArray(); foreach (var item in result) { item.CanDelete = true; } var sqlc = Sql.SqlQueryCach["Train.CountAll"]; var count = conn.ExecuteScalar <int>(sqlc); var output = new TrainPaging { Data = result, Total = count }; return(output); } }