示例#1
0
        private bool ByMemberName(out object?result, string memberName)
        {
            var value = _getter(_item, memberName);

            result = DBNullHelper.FromDb(value);
            return(true);
        }
示例#2
0
        public void FromDb_NonNullString_ShouldStaySame()
        {
            object input = "xyz";
            object o     = DBNullHelper.FromDb(input);

            Assert.AreEqual(input, o);
        }
示例#3
0
        public void FromDb_BoxedInteger_ShouldStaySame()
        {
            object input = 1;
            object o     = DBNullHelper.FromDb(input);

            Assert.AreEqual(input, o);
        }
示例#4
0
        public void FromDb_NullReference_ShouldBeNull()
        {
            object input = null;
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            object o = DBNullHelper.FromDb(input);

            // ReSharper restore ConditionIsAlwaysTrueOrFalse
            Assert.IsNull(o);
        }
示例#5
0
        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);
        }
示例#6
0
        public void FromDb_DBNullValue_ShouldBeNull()
        {
            object o = DBNullHelper.FromDb(DBNull.Value);

            Assert.IsNull(o);
        }