Пример #1
0
        public IdAccessor(IStructureProperty property)
            : base(property)
        {
            if (!property.IsRootMember)
            {
                throw new SisoDbException(ExceptionMessages.IdAccessor_InvalidLevel);
            }

            if (!StructureId.IsValidDataType(property.DataType))
            {
                throw new SisoDbException(ExceptionMessages.IdAccessor_UnsupportedPropertyType.Inject(Property.DataType.Name));
            }

            IdType = StructureId.GetIdTypeFrom(property.DataType);

            _getter = StructureIdGetters.For(IdType, Property.DataType);
            _setter = StructureIdSetters.For(IdType, Property.DataType);
        }
Пример #2
0
 public void GetIdTypeFrom_WhenNullableLong_ReturnsIdTypeOfIdentity()
 {
     Assert.AreEqual(StructureIdTypes.BigIdentity, StructureId.GetIdTypeFrom(typeof(long?)));
 }
Пример #3
0
 public void GetIdTypeFrom_WhenNullableInt_ReturnsIdTypeOfIdentity()
 {
     Assert.AreEqual(StructureIdTypes.Identity, StructureId.GetIdTypeFrom(typeof(int?)));
 }
Пример #4
0
 public void GetIdTypeFrom_WhenNullableGuid_ReturnsIdTypeOfGuid()
 {
     Assert.AreEqual(StructureIdTypes.Guid, StructureId.GetIdTypeFrom(typeof(Guid?)));
 }
Пример #5
0
 public void GetIdTypeFrom_WhenString_ReturnsIdTypeOfString()
 {
     Assert.AreEqual(StructureIdTypes.String, StructureId.GetIdTypeFrom(typeof(string)));
 }