简体   繁体   English

是否等效于NHibernate中的Hibernate的@embeddable / EF的ComplexTypeConfiguration?

[英]Equivalent to Hibernate's @embeddable / EF's ComplexTypeConfiguration in NHibernate?

Is there an equivalent to Hibernate's @embeddable annotation / Entity Framework's ComplexTypeConfiguration base class in NHibernate? NHibernate中是否有与Hibernate的@embeddable注释/ Entity Framework的ComplexTypeConfiguration基类等效的类?

I'm aware of the possibility of a 1:1 mapping, but I'm looking for a solution that embeds the values in the parent entitys table. 我知道1:1映射的可能性,但是我正在寻找一种将值嵌入父实体表中的解决方案。

Based on a quick look at the Hibernate @embeddable attribute, it is basically a component that can be re-used in multiple places. 快速浏览Hibernate @embeddable属性后,它基本上是一个可以在多个地方重复使用的组件。 NHibernate does not support this out-of-the-box, but you can accomplish this using Fluent NHibernate's ComponentMap : NHibernate不支持此功能,但是您可以使用Fluent NHibernate的ComponentMap来实现:

Component(x => x.Address, m =>
{
  m.Map(x => x.Number);
  m.Map(x => x.Street);
  m.Map(x => x.PostCode);
});

It doesn't appear that ComponentMap's have quite as much flexibility for overriding column definitions, though you can prefix columns to allow duplicate components in the same entity. 尽管您可以为列添加前缀以允许同一实体中的重复组件,但ComponentMap似乎没有足够的灵活性来覆盖列定义。 (eg ComponentMap with HomeAddress and WorkAddress on a Person.) (例如,ComponentMap上具有HomeAddress和WorkAddress的人员。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM