如何解决如何在流畅的 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 举报,一经查实,本站将立刻删除。