Fluent nhibernate Fluent nhibernate映射问题:使用附加数据的多对多自联接

Fluent nhibernate Fluent nhibernate映射问题:使用附加数据的多对多自联接,fluent-nhibernate,nhibernate-mapping,many-to-many,Fluent Nhibernate,Nhibernate Mapping,Many To Many,我正在努力处理以下sql表的映射 |Post | |PostRelation | |------------------| |-----------------| |PostId |1--------*|ParentPostId | |---other stuff--- |1--------*|ChildPostId | |

我正在努力处理以下sql表的映射

   |Post              |          |PostRelation     |
   |------------------|          |-----------------|
   |PostId            |1--------*|ParentPostId     |
   |---other stuff--- |1--------*|ChildPostId      |
   |                  |          |RelationType     |
理想情况下,我希望post上有一个名为relatedPosts的属性

 Dictionary <RelationType,IList<Post>>
字典
但现在我只想在邮局买一套房子

  IList<PostRelation>.
IList。
我成功地使用了多对多方法来获取相关帖子,但这种方法会丢失附加数据


有什么建议吗?

经过大量研究,我终于找到了解决办法。所以尽管我会把它贴出来,以防将来它能帮助其他人。 因为PostRelation有额外的数据,所以它本身需要是一个实体

——PostRelationMap

        Id(x => x.Id, "PostRelationId").GeneratedBy.Identity();

        References(x => x.ParentPost, "ParentPostId")
            .ForeignKey("FK_PostRelation_ParentPost")
            .Fetch.Join()
            .LazyLoad();

        References(x => x.ChildPost, "ChildPostId")
            .ForeignKey("FK_PostRelation_ChildPost")
            .Fetch.Join()
            .LazyLoad();

        Map(x => x.RelationshipType).CustomType<int>().Not.Nullable();
    HasMany(x => x.ChildPosts)
            .Access.CamelCaseField(Prefix.Underscore)
            .Cascade.AllDeleteOrphan()
            .KeyColumn("ChildPostId")
            .LazyLoad();