I'm a newbie to NHibernate and am wondering how to best handle the following scenario. Lets say I have a contact management application with company, contact, and address entities. A company and a contact can each have multiple addresses. I'd like to have the addresses defined in a single table with the following columns:
Id
ReferenceId
ReferenceType
Address1
Address2
City
State
Zip
etc.
The ReferenceId is a foreign key to either the Contacts table or the Companies table, depending on the value of the ReferenceType field. Could this be done using a discriminator?
|