private static File MapFile(IDataReader reader, ref int startingIndex) { File file; file = new File(); file.Id = reader.GetSafeInt32(startingIndex++); file.Url = reader.GetSafeString(startingIndex++); file.FileTypeId = reader.GetSafeInt32(startingIndex++); file.CreatedBy = reader.GetSafeInt32(startingIndex++); file.DateCreated = reader.GetDateTime(startingIndex++); return(file); }
public File Get(int id) { string procName = "dbo.Files_Select_ById"; File file = null; _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection collection) { collection.AddWithValue("@Id", id); }, singleRecordMapper : delegate(IDataReader reader, short set) { int startingIndex = 0; file = MapFile(reader, ref startingIndex); }); return(file); }
public Paged <File> GetByCreatedBy(int pageIndex, int pageSize, int createdBy) { string procName = "dbo.Files_Select_ByCreatedBy"; Paged <File> pagedResult = null; List <File> result = null; int totalCount = 0; _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection collection) { collection.AddWithValue("@PageIndex", pageIndex); collection.AddWithValue("@PageSize", pageSize); collection.AddWithValue("@CreatedBy", createdBy); }, singleRecordMapper : delegate(IDataReader reader, short set) { int startingIndex = 0; File file = MapFile(reader, ref startingIndex); if (totalCount == 0) { totalCount = reader.GetSafeInt32(startingIndex++); } if (result == null) { result = new List <File>(); } result.Add(file); }); if (result != null) { pagedResult = new Paged <File>(result, pageIndex, pageSize, totalCount); } return(pagedResult); }