nhibernate: using parts of the compositeId in a ManyToOne Property

后端 未结 2 1482
时光取名叫无心
时光取名叫无心 2020-12-12 07:10

I have a tablestructure like this:

Table entity
(
    otherEntity_id  int  // primarykey
    id              int  // primarykey

    parent_id       int
)


        
相关标签:
2条回答
  • 2020-12-12 07:37

    I still haven't found a solution and mapped changed my model to:

    public class Entity
    {
        public OtherEntity Other { get; set; }
        // simple int to discriminate different Entity for the same OtherEntity
        public int Id { get; set; }
    
        public int ParentId { get; set; }
    }
    
    0 讨论(0)
  • 2020-12-12 07:49

    If you are referencing the same column above twice (otherEntity_id) I've seen mappings like this to avoid this sort of error:

    References(e => e.Parent).Columns("otherEntity_id", "parent_id")
        .Not.Update()
        .Not.Insert();
    

    Also when you are running into a problem it is always helpful to show the full error message you are running into.

    0 讨论(0)
提交回复
热议问题