开发者

NHibernate One-To-Many Using A Join Table

开发者 https://www.devze.com 2023-01-07 22:17 出处:网络
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

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消