NHibernate:自我引用多对多配置问题

时间:2012-09-11 13:33:18

标签: c# nhibernate fluent-nhibernate

我试图理解为什么我会收到此错误:

The relationship Client.ChildClients to Client.ChildClients has Inverse specified on both sides. Remove Inverse from one side of the relationship.

我有一个包含这些属性的客户端实体:

    public virtual Iesi.Collections.ISet ChildClients
    {
        get
        {
            return this._ChildClients;
        }
        set
        {
            this._ChildClients = value;
        }
    }

    public virtual Iesi.Collections.ISet ParentClients
    {
        get
        {
            return this._ParentClients;
        }
        set
        {
            this._ParentClients = value;
        }
    }

当我尝试流利地配置我的映射时,我收到了上面列出的错误。 这是我对这些属性的映射:

HasManyToMany<Client>(x => x.ChildClients)
          .Access.Property()
          .AsSet()
          .Cascade.None()
          .LazyLoad()
          .Inverse()
          .Not.Generic()
          .Table("ParentClients_ChildClients")
          .FetchType.Join()
          .ChildKeyColumns.Add("ClientId1", mapping => mapping.Name("ClientId1")
                                                               .Nullable())
          .ParentKeyColumns.Add("ClientId", mapping => mapping.Name("ClientId")
                                                               .Nullable());
HasManyToMany<Client>(x => x.ParentClients)
          .Access.Property()
          .AsSet()
          .Cascade.None()
          .LazyLoad()
          .Not.Generic()
          .Table("ParentClients_ChildClients")
          .FetchType.Join()
          .ChildKeyColumns.Add("ClientId", mapping => mapping.Name("ClientId")
                                                               .Nullable())
          .ParentKeyColumns.Add("ClientId1", mapping => mapping.Name("ClientId1")
                                                               .Nullable());

我试图弄清楚我的问题及其发生的原因。我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

解决here!问题似乎是流利的nhibernate验证器或其他东西。希望我知道为什么要修复它。

相关问题