0
我想映射一个Person
对象。在NHibernate中将两个一对多关系映射到一个集合中
我得到People
表PersonId
,FatherId
和MotherId
字段(等)。最后两个参考文献PersonId
在同一张表中。
在我的域模型,我想有一个Children
只读集合与所有其他Person
将其具有的FatherId
或MotherId
于母公司的PersonId
。要做到这一点
一种方法是使用两个HasMany
和地图分别以FatherId
和MotherId
外键进入FathersChildren
和MothersChildren
集合并返回那些在Children
吸气取决于父母的性别之一。但是,这让我的领域对象变得丑陋,可以这么说。
有什么办法可以解决这个问题吗?我会很高兴与流利或hbm。
只是一个想法:您可以使用IGetter/ISetter的实现将FatchersChildren和MothersChildren映射为虚拟属性,以*将列表*或*设置为取决于性别*的列表。这是你需要的一些额外的代码 – Firo 2012-03-15 11:09:33