Is there a way to map a many-to-many relationship with properties on each item in the list specific to the relationship? The actual case I'm trying to solve is this:
A business can be related to many contacts, and a contact can be related to many businesses. What I want to do is provide a status for the relationship, like active or deleted and a date the contact was invited (or added) to be a contact for that business. So say a contact can be active for one business, but pending for another business.
I know I can easily achieve this by just making the relationship an actual entity and mapping the association entity to the collections, but I REALLY hate doing that. It just feels dirty making something like a relationship an actual entity. What I'm wondering is if there's a way to map the relationship specific properties to each object. So, say I have the list of contacts for a business. Each contact in that list would have a status, but in the mapping it would make that status specific to the business. I was hoping I could do something like this in what would be the business mapping:
<bag name="Contacts" table="BusinessContactAssociations" lazy="true" cascade="all">
<key column="BusinessID"/>
<many-to-many class="Contact" column="ContactID">
<join table="BusinessContactAssociations">
<key column="ContactID"/>
<property name="InvitedDate"/>
<property name="Status"/>
</join>
</many-to-many>
</bag>
but of course that doesn't work, because join can't be used within a many-to-many, but it illustrates what I want.
Anyone have any handy nhibernate mapping magic for me?