NHibernate Many To Many参考帮助

时间:2011-04-04 09:40:06

标签: fluent-nhibernate

我有2个表(实体),如下所示

NewsLetter
-------------------
Id
UserEmail
AgreeToReceiveNewsLetters
DateRegisted

Voucher
-------------------
Id
Code
IsActive
PromoText
CreatedDate
MaxDaysToRedeem

和多对多关系的第三个参考表

NewsLetterVoucher
-------------------
Id
NewsLetter_id
Voucher_id
ValidFrom
ValidUntil
DateRedeemed
DateNotified

所有这些都很好地解决了多对多关系工作的好处 问题是我希望在实体模型中访问存储在参考表中的附加信息(ValidFrom,ValidUntil等)

就像

一样
  

NewsLetter.Voucher [0] .ValidFrom

但ValidFrom存储在refenece表中

我该怎么做

2 个答案:

答案 0 :(得分:2)

有一个类似的问题(NHibernate: Many-to-many relationship with field in the relationship table)。您需要将关系表映射为类。

答案 1 :(得分:1)

如果我理解正确的话,我认为这是解决您问题的方法。

fluent nhibernate - Many to Many mapping with attribute