示例#1
0
        public static List <TObject> GetItemsList <TObject>(DataReaderAdapter dataReader, Func <DataReaderAdapter, TObject> createObject)
        {
            if (createObject == null)
            {
                throw new ArgumentNullException("createObject");
            }

            List <TObject> result = new List <TObject>();

            if (dataReader != null)
            {
                while (dataReader.Read())
                {
                    TObject item = createObject(dataReader);
                    result.Add(item);
                }
            }

            return(result);
        }
示例#2
0
        public static List <TObject> GetItemsList <TObject>(IMapper <TObject> mapper, DataReaderAdapter dataReader)
            where TObject : new()
        {
            if (mapper == null)
            {
                throw new ArgumentNullException("mapper");
            }

            List <TObject> result = new List <TObject>();

            if (dataReader != null)
            {
                while (dataReader.Read())
                {
                    TObject item = new TObject();
                    mapper.Fill(dataReader, item);
                    result.Add(item);
                }
            }

            return(result);
        }
示例#3
0
 public static List <TObject> GetItemsList <TObject, TMapper>(DataReaderAdapter dataReader)
     where TObject : new()
     where TMapper : IMapper <TObject>, new()
 {
     return(GetItemsList(new TMapper(), dataReader));
 }
示例#4
0
 public static TObject GetFirstItem <TObject, TMapper>(DataReaderAdapter dataReader, Func <TObject> createObject)
     where TMapper : IMapper <TObject>, new()
 {
     return(GetFirstItem(new TMapper(), dataReader, createObject));
 }
示例#5
0
 public static TObject GetFirstItem <TObject>(IMapper <TObject> mapper, DataReaderAdapter dataReader)
     where TObject : new()
 {
     return(GetFirstItem(mapper, dataReader, () => new TObject()));
 }
示例#6
0
        public static Dictionary <TKey, List <TObject> > GetGroupedItemsList <TObject, TMapper, TKey>(string keyFieldName, DataReaderAdapter dataReader)
            where TObject : new()
            where TMapper : IMapper <TObject>, new()
        {
            var mapper = new TMapper();
            List <Tuple <TKey, TObject> > list = new List <Tuple <TKey, TObject> >();

            if (dataReader != null)
            {
                while (dataReader.Read())
                {
                    TKey    key  = dataReader.GetValue <TKey>(keyFieldName);
                    TObject item = new TObject();
                    mapper.Fill(dataReader, item);
                    list.Add(new Tuple <TKey, TObject>(key, item));
                }
            }

            return(list.GroupBy(x => x.Item1)
                   .ToDictionary(x => x.Key, x => x.Select(i => i.Item2).ToList()));
        }
示例#7
0
        public static List <NameValue <TValue, TKey> > GetNameValueList <TValue, TKey>(DataReaderAdapter dataReader, string valueField, string keyField)
        {
            var result = new List <NameValue <TValue, TKey> >();

            if (dataReader != null)
            {
                while (dataReader.Read())
                {
                    result.Add(new NameValue <TValue, TKey>(dataReader.GetValue <TValue>(valueField), dataReader.GetValue <TKey>(keyField)));
                }
            }

            return(result);
        }
示例#8
0
 public static List <NameValue <TValue, TKey> > GetNameValueList <TValue, TKey>(DataReaderAdapter dataReader)
 {
     return(GetNameValueList <TValue, TKey>(dataReader, "Value", "Key"));
 }
示例#9
0
        public static List <TObject> GetValueItemsList <TObject>(IValueMapper <TObject> mapper, DataReaderAdapter dataReader)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException("mapper");
            }

            List <TObject> result = new List <TObject>();

            if (dataReader != null)
            {
                while (dataReader.Read())
                {
                    result.Add(mapper.GetValue(dataReader));
                }
            }

            return(result);
        }
示例#10
0
 public static TObject GetFirstItem <TObject, TMapper>(DataReaderAdapter dataReader)
     where TObject : new()
     where TMapper : IMapper <TObject>, new()
 {
     return(GetFirstItem(new TMapper(), dataReader));
 }