DO 5.0.20

Simple model example:

class AnotherReferenceType : Entity
    public AnotherReferenceType(Guid id): base(id) { }

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


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%20Grishin's gravatar image

Nikita Grishin

One Answer:

Hello Nikita,

I have reproduced the issue. This is not the attribute this is virtual property. I guess the only hierarchy type where it is theoretically may be allowed is ConcreteTable due each table contains full set of fields inherited from ancestor.

I created task for that problem.

answered Jul 28 '20 at 10:07

Alexey%20Kulakov's gravatar image

Alexey Kulakov

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA