public async Task <IPagedResults <File> > SelectAsync(IDbDataParameter[] dbParams) { IPagedResults <File> output = null; using (var context = _dbContext) { output = await context.ExecuteReaderAsync <IPagedResults <File> >( CommandType.StoredProcedure, "SelectFilesPaged", async reader => { if ((reader != null) && (reader.HasRows)) { output = new PagedResults <File>(); while (await reader.ReadAsync()) { var entity = new Models.File(); entity.PopulateModel(reader); output.Data.Add(entity); } if (await reader.NextResultAsync()) { await reader.ReadAsync(); output.PopulateTotal(reader); } } return(output); }, dbParams); } return(output); }
public async Task <File> SelectByIdAsync(int id) { Models.File file = null; using (var context = _dbContext) { file = await context.ExecuteReaderAsync <Models.File>( CommandType.StoredProcedure, "SelectFileById", async reader => { if ((reader != null) && reader.HasRows) { await reader.ReadAsync(); file = new Models.File(); file.PopulateModel(reader); } return(file); }, new IDbDataParameter[] { new DbParam("Id", DbType.Int32, id) }); } return(file); }