DO 5.0.20
Simple model example:
[HierarchyRoot]
class AnotherReferenceType : Entity
{
public AnotherReferenceType(Guid id): base(id) { }
}
[HierarchyRoot(InheritanceSchema.ConcreteTable)]
class EntityBase : Entity
{
public EntityBase(Guid id) : base(id) { }
[Field(Nullable = true)]
public virtual AnotherReferenceType Reference { get; set; }
}
class DerivedEntity : Entity
{
public DerivedEntity(Guid id) : base(id) { }
[Field(Nullable = false, DefaultValue = "36C6B295-6FE6-4A18-8C40-86DA92592BEA")] // override default value and nullability
public override AnotherReferenceType Reference { get; set; }
}
How to check:
// AnotherReferenceType instance with specified Id as default must exists in DB
Assert.Null(new EntityBase(Guid.NewGuid()).Reference);
Assert.NotNull(new DerivedEntity(Guid.NewGuid()).Reference); // this assertion fails
Explanation:
When I trying to create instance of DerivedEntity, I receiving result without override.
In this scenario TypeInfo for DerivedEntity from Domain.Model.Types collection doesn't contains valid UnderlyingProperty for overriden field.
This collection contains FieldInfo.UnderlyingProperty for base type with null as DefaultValue.
As result, FieldInfo for overriden Reference property doesn't contains valid DefaultValue from FieldAttribute.
This case replays in both persistent hierarchies: ClassTable and ConcreteTable.
asked
Jul 23 '20 at 09:08
Nikita Grishin
5●1●1●1