public static async Task <Dictionary <TKey, List <T> > > LoadDictionaryAsync <T, TKey>( this DbDataReader reader, MapDefinition <T> mapDefinition, string keyColumn) where T : new() { var result = new Dictionary <TKey, List <T> >(); if (reader.HasRows == false) { return(result); } var keyOrdinal = reader.GetOrdinal(keyColumn); var map = CreateMap(reader, mapDefinition); if (mapDefinition.HasSqlServerSpecificFields == false) { return(await ReadDictionaryAsync(reader, keyOrdinal, result, map)); } var sqlReader = new SqlDataReaderShim((SqlDataReader)reader); var sqlMap = (ISqlMap <T>)map; return(await ReadSqlServerSpecificDictionaryAsync(sqlReader, keyOrdinal, result, sqlMap)); }
private static IMap <T> CreateMap <T>(IDataRecord reader, MapDefinition <T> mapDefinition) where T : new() { var map = mapDefinition.CreateMap(); map.LoadOrdinals(reader); return(map); }
public static async Task <T> LoadSingleAsync <T>( this DbDataReader reader, MapDefinition <T> mapDefinition) where T : new() { if (await reader.ReadAsync() == false) { return(default(T)); } var map = CreateMap(reader, mapDefinition); if (mapDefinition.HasSqlServerSpecificFields == false) { return(LoadItem(reader, map)); } var sqlReader = new SqlDataReaderShim((SqlDataReader)reader); var sqlMap = (ISqlMap <T>)map; return(LoadItemWithSqlServerSpecificField(sqlReader, sqlMap)); }
public static async Task <List <T> > LoadListAsync <T>( this DbDataReader reader, MapDefinition <T> mapDefinition) where T : new() { var list = new List <T>(); if (reader.HasRows == false) { return(list); } var map = CreateMap(reader, mapDefinition); if (mapDefinition.HasSqlServerSpecificFields == false) { return(await ReadListAsync(reader, map, list)); } var sqlReader = new SqlDataReaderShim((SqlDataReader)reader); var sqlMap = (ISqlMap <T>)map; return(await ReadSqlServerSpecificListAsync(sqlReader, sqlMap, list)); }