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); }
protected virtual Converter <object, T> GetTypeConverter <T>() { return((object o) => (T)DBConvert.To <T>(o)); }
public static T Get <T>(this DbDataReader reader, string name) { return(DBConvert.To <T>(reader[name], CultureInfo.CurrentCulture)); }
public static T Get <T>(this DbDataReader reader, string name, IFormatProvider provider) { return(DBConvert.To <T>(reader[name], provider)); }
public static T Get <T>(this DbDataReader reader, int ordinal) { return(DBConvert.To <T>(reader[ordinal], CultureInfo.CurrentCulture)); }
public static T Get <T>(this DbDataReader reader, int ordinal, IFormatProvider provider) { return(DBConvert.To <T>(reader[ordinal], provider)); }