1

I have 2 tables (entities) like the following

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

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

and a third reference table for many to many relationhip

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

All is working good the the mappings for the many to many relationship working good The problem is that I want to have access in the entity model at the additional information that are stored in the reference table (ValidFrom , ValidUntil etc)

just like

NewsLetter.Voucher[0].ValidFrom

but ValidFrom is stored in the refenece table

How I can do that

Spyros
  • 540
  • 1
  • 7
  • 21
  • I think both Circadian and Stefan have what you are looking for below. You really need two one to many relationships here. One from NewsLetter and one from Voucher to a 3rd class called NewsLetterVoucher. – Cole W Apr 04 '11 at 11:49

2 Answers2

2

There is a similar question (NHibernate: Many-to-many relationship with field in the relationship table). You need to map the relation table as a class.

Community
  • 1
  • 1
Stefan Steinegger
  • 63,782
  • 15
  • 129
  • 193
1

I think this is a solution to your problem, if I understand it correctly.

fluent nhibernate - Many to Many mapping with attribute

Community
  • 1
  • 1
Alexandros B
  • 1,881
  • 1
  • 23
  • 36