开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜