NHibernate One-To-Many Using A Join Table
Is this possible without mapping the join table to a domain entity?
For example if I have the following three tables, account and note are joined by the table account_note.开发者_开发问答 Can i map a collection of notes to account class with a one to many mapping?
1 to M | 1 to M
Account -> Account_Note -> Note
You need to use a many-to-many
element.
Example:
<class name="Account">
<id .../>
<bag name="Notes" table="Account_Note">
<key column="AccountId"/>
<many-to-many class="Note" column="NoteId"/>
</bag>
</class>
精彩评论