NHibernate单列id引用另一个对象
我有一个类,其主键是单列,它是对另一个对象的单列主键的引用。我能看到在 NHibernate 中映射它的唯一方法是假装它是一个复合键(即使它是一个单列键)并使用键引用映射。有没有更合适的方法呢?
下面的片段:
class CompanyExportCriteria
public Company Company { get; set; }
class Company
public string Id { get; set; }
公司映射到 COMPANY 表(ID 为 PK)
CompanyExportCriteria 映射到 COMPANY_EXPORT_CRITERIA 表 (COMPANY_ID) 作为键。
PS - 我正在使用 Fluent NHibernate 进行映射。
I have a class whose primary key is a single column, which is a reference to another object's single column primary key. The only way I can see to map this in NHibernate is to pretend it's a composite key (even though it's a single column key) and use the key-reference mapping. Is there a more appropriate way?
Snippet below:
class CompanyExportCriteria
public Company Company { get; set; }
class Company
public string Id { get; set; }
Company maps to a COMPANY table (ID as PK)
CompanyExportCriteria maps to a COMPANY_EXPORT_CRITERIA table (COMPANY_ID) as key.
PS - I am using Fluent NHibernate for mapping.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是 Fluent NHibernate 的一对一映射文档的链接:
http: //wiki.fluentnhibernate.org/Fluent_mapping#HasOne_.2F_one-to-one
这是 NHibernate 相同内容的链接:
http://www.nhforge.org/doc/nh/en/index.html#mapping-declaration-onetoone
你应该不需要复合键。
Here's a link to the one-to-one mapping documentation for Fluent NHibernate:
http://wiki.fluentnhibernate.org/Fluent_mapping#HasOne_.2F_one-to-one
Here's a link to the same thing for NHibernate:
http://www.nhforge.org/doc/nh/en/index.html#mapping-declaration-onetoone
You shouldn't need a composite key.