Пример #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);
        }
Пример #2
0
 protected virtual Converter <object, T> GetTypeConverter <T>()
 {
     return((object o) => (T)DBConvert.To <T>(o));
 }