internal static void SetProperty <T>(this IDataRecord reader, T obj, IDBColumnMapping <T> mapping, Action <T, IDataRecord, int> setter, int ordinal) { try { setter(obj, reader, ordinal); } catch (Exception ex) { string colName = mapping.ColumnName; throw new FormatException("Failed to Parse [" + typeof(T).Name + "." + colName + "] from DataReader!", ex); } }
public DBColumnMappingInfo(IDBColumnMapping <T> mapping, SchemaMetadata metadata) { ColumnName = mapping.ColumnName; NoInsert = mapping.NoInsert; NoUpdate = mapping.NoUpdate; Required = mapping.Required; ObjectProperty = mapping.ObjectProperty; PropertyGetter = mapping.PropertyGetter; //PropertySetter = mapping.PropertySetter; ColumnName = metadata.COLUMN_NAME; TableName = metadata.TABLE_NAME; DataType = metadata.DATA_TYPE; CharLength = metadata.CHAR_LENGTH; DataPrecision = metadata.DATA_PRECISION; DataScale = metadata.DATA_SCALE; Required = Required || metadata.NULLABLE == "N"; PK = metadata.PK == "Y"; // recreate setter as the Required condition may be changed. PropertySetter = CreateSetter(ObjectProperty, !Required); }
private Parameter CreateInputParameter(IDBColumnMapping <T> colInfo, T obj, ParameterDirection direction) { return(new Parameter(colInfo.ColumnName, colInfo.PropertyGetter(obj), direction)); }