Hi,

I noticed that the check for the 'PairTo' in the AssociationAttribute is not checked. As a matter of fact the Association is not honoured at all when the 'PairTo' is wrong (in other words: The one-to-many table is not created in the DB).

Regards Paul

asked Sep 10 '14 at 08:13

Paul%20Sinnema's gravatar image

Paul Sinnema
261878896


2 Answers:

Hi Paul.

PairTo checks when DO builds associations. It is like in DO 4.6.

answered Sep 10 '14 at 09:51

Alexey%20Kulakov's gravatar image

Alexey Kulakov
71715

See the comment below

(Sep 12 '14 at 08:12) Paul Sinnema Paul%20Sinnema's gravatar image

We have the code below. The association is wrong because there is no 'Notitie' on the FactuurEntity. There is a 'NotitieId' present. The association is NOT produced in the DB. The RootEntity contains the Id of the entities and has a HierachyRoot attribute and a key generator.

using Xtensive.Orm;

namespace Fortrus.DataWarehouse.Model
{
    [TableMapping("Notitie")]
    [Index("NotitieId", Name = "IndexNotitieNotitieId")]
    public partial class NotitieEntity : RootEntity
    {
        [Field(Nullable = false)]
        public long NotitieId { get; set; }

        [Association(OnOwnerRemove = OnRemoveAction.Cascade,
             OnTargetRemove = OnRemoveAction.Clear, PairTo = "Notitie")]
        public EntitySet<FactuurEntity> FactuurList { get; set; }
    }
}

using System;
using Xtensive.Orm;

namespace Fortrus.DataWarehouse.Model
{
    [TableMapping("Factuur")]
    [Index("FactuurId", Name = "IndexFactuurFactuurId")]
    [Index("NotitieId", Name = "IndexFactuurNotitieId")]
    public partial class FactuurEntity : RootEntity
    {
        [Field(Nullable = false)]
        public long FactuurId { get; set; }

        [Field(Nullable=false)]
        public long NotitieId { get; set; }
    }
}

answered Sep 12 '14 at 08:12

Paul%20Sinnema's gravatar image

Paul Sinnema
261878896

edited Sep 15 '14 at 03:53

Hi.

I see you missed FieldAttribute for FactuurList field. When FieldAttribute didn't define for field, then DO didn't process other attributes like AssociationAttribute, FieldMappingAttribute or Validators attributes.

(Sep 15 '14 at 04:21) Alexey Kulakov Alexey%20Kulakov's gravatar image

Yep you're right. Missed that.

(Sep 17 '14 at 01:46) Paul Sinnema Paul%20Sinnema's gravatar image
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