internal PocoModelSchema GetSchema(Type t) { PocoModelSchema schema = null; if (!SchemaCache.TryGetValue(t, out schema)) { schema = InferSchema(t); SchemaCache[t] = schema; } return(schema); }
internal void MapTo(IDataRecord record, object o, Type type, PocoModelSchema schema) { for (int i = 0; i < record.FieldCount; i++) { var fieldName = record.GetName(i); var colMapping = schema.GetColumnMapping(fieldName); if (colMapping == null || colMapping.SetVal == null) { continue; } var fieldValue = record.GetValue(i); if (DataHelper.IsNullOrDBNull(fieldValue)) { fieldValue = null; if (Nullable.GetUnderlyingType(colMapping.ValueType) == null && colMapping.ValueType._IsValueType()) { fieldValue = colMapping.DefaultValue; } } colMapping.SetValue(o, fieldValue); } }