Esempio n. 1
0
        public T Convert(DbDataReader reader)
        {
            if (_mappings == null || reader != _lastReader)
            {
                _mappings = MapProperties(reader);
            }

            var o = new T();

            foreach (var mapping in _mappings)
            {
                var prop     = mapping.Property;
                var rawValue = reader.GetValue(mapping.Index);
                var value    = DBConvert.To(prop.PropertyType, rawValue);
                prop.SetValue(o, value, null);
            }

            _lastReader = reader;

            return(o);
        }
Esempio n. 2
0
 protected virtual Converter <object, T> GetTypeConverter <T>()
 {
     return((object o) => (T)DBConvert.To <T>(o));
 }
Esempio n. 3
0
 public static T Get <T>(this DbDataReader reader, string name)
 {
     return(DBConvert.To <T>(reader[name], CultureInfo.CurrentCulture));
 }
Esempio n. 4
0
 public static T Get <T>(this DbDataReader reader, string name, IFormatProvider provider)
 {
     return(DBConvert.To <T>(reader[name], provider));
 }
Esempio n. 5
0
 public static T Get <T>(this DbDataReader reader, int ordinal)
 {
     return(DBConvert.To <T>(reader[ordinal], CultureInfo.CurrentCulture));
 }
Esempio n. 6
0
 public static T Get <T>(this DbDataReader reader, int ordinal, IFormatProvider provider)
 {
     return(DBConvert.To <T>(reader[ordinal], provider));
 }