private bool ByMemberName(out object?result, string memberName) { var value = _getter(_item, memberName); result = DBNullHelper.FromDb(value); return(true); }
public void FromDb_NonNullString_ShouldStaySame() { object input = "xyz"; object o = DBNullHelper.FromDb(input); Assert.AreEqual(input, o); }
public void FromDb_BoxedInteger_ShouldStaySame() { object input = 1; object o = DBNullHelper.FromDb(input); Assert.AreEqual(input, o); }
public void FromDb_NullReference_ShouldBeNull() { object input = null; // ReSharper disable ConditionIsAlwaysTrueOrFalse object o = DBNullHelper.FromDb(input); // ReSharper restore ConditionIsAlwaysTrueOrFalse Assert.IsNull(o); }
private static T MapTo <T>(this IDataRecord record, DbConfig config) { var convention = config.MappingConvention; var setters = FastReflection.Instance.GetSettersForType <T>(); var result = Activator.CreateInstance <T>(); for (var i = 0; i < record.FieldCount; i++) { var columnName = convention.FromDb(record.GetName(i)); if (!setters.TryGetValue(columnName, out var setter)) { continue; } var val = DBNullHelper.FromDb(record.GetValue(i)); setter(result, val); } return(result); }
public void FromDb_DBNullValue_ShouldBeNull() { object o = DBNullHelper.FromDb(DBNull.Value); Assert.IsNull(o); }