public async Task <IPagedResults <Attachment> > SelectAsync(IDbDataParameter[] dbParams) { IPagedResults <Attachment> output = null; using (var context = _dbContext) { output = await context.ExecuteReaderAsync <IPagedResults <Attachment> >( CommandType.StoredProcedure, "SelectAttachmentsPaged", async reader => { if ((reader != null) && (reader.HasRows)) { output = new PagedResults <Attachment>(); while (await reader.ReadAsync()) { var entity = new Models.Attachment(); 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 <Attachment> SelectByIdAsync(int id) { Models.Attachment attachment = null; using (var context = _dbContext) { attachment = await context.ExecuteReaderAsync <Models.Attachment>( CommandType.StoredProcedure, "SelectAttachmentById", async reader => { if ((reader != null) && reader.HasRows) { await reader.ReadAsync(); attachment = new Models.Attachment(); attachment.PopulateModel(reader); } return(attachment); }, new IDbDataParameter[] { new DbParam("Id", DbType.Int32, id) }); } return(attachment); }