如何在流畅的 NHibernate 中创建外键关系而不持有对父实体的引用

问题描述

我无法使用此设置创建外键关系。请帮忙! 我有 3 个班级:

Class Father
{
    Public Guid Id //This is the PK but I DON'T want to use this
    Public GuidWrapper myRealId //I need to use this unique id for the relation ship
}
Class Child
{
    Public Guid Id //not relevant. just to clarify this it the PK
    Public GuidWrapper dadId //I need to use this unique id for the relation ship
}
Class GuidWrapper
{
    Public Guid guid
}

我还有这些父表和子表的相关列:

Father table:
 column: myRealIdIdentifier uniqueidentifier
Child table:
 column: dadIdIdentifier uniqueidentifier

我在 fluent Nhibernate 中尝试做的事情(使用自动映射,但我可以进行覆盖)是创建一个启用级联删除的外键关系,其中孩子指向父亲的 myRealId,这不是 PK。

注意孩子没有对父亲的引用,我宁愿使用 GuidWrapper 作为外键属性。另请注意,基础列名称属性不同。

我尝试了各种变体,但无济于事,因为我是 Nhibernate 的新手:

childAutoMapping.References<Father>(x => x.dadId).Column("dadIdIdentifier")
                        .PropertyRef("myRealId");

任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)