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); }
public void GetIdTypeFrom_WhenNullableLong_ReturnsIdTypeOfIdentity() { Assert.AreEqual(StructureIdTypes.BigIdentity, StructureId.GetIdTypeFrom(typeof(long?))); }
public void GetIdTypeFrom_WhenNullableInt_ReturnsIdTypeOfIdentity() { Assert.AreEqual(StructureIdTypes.Identity, StructureId.GetIdTypeFrom(typeof(int?))); }
public void GetIdTypeFrom_WhenNullableGuid_ReturnsIdTypeOfGuid() { Assert.AreEqual(StructureIdTypes.Guid, StructureId.GetIdTypeFrom(typeof(Guid?))); }
public void GetIdTypeFrom_WhenString_ReturnsIdTypeOfString() { Assert.AreEqual(StructureIdTypes.String, StructureId.GetIdTypeFrom(typeof(string))); }