Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your classes would look like the following</p> <pre><code>public class User { public virtual int UserId { get; set; } public virtual string UserName { get; set; } public virtual IList&lt;UserRating&gt; Ratings { get; set; } } public class Item { public virtual int ItemId { get; set; } public virtual string ItemName { get; set; } public virtual IList&lt;UserRating&gt; Ratings { get; set; } } public class UserRating { public virtual User User { get; set; } public virtual Item Item { get; set; } public virtual Int32 Rating { get; set; } } </code></pre> <p>Your mapping file would look like </p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Test" namespace="Test" &gt; &lt;class name="User"&gt; &lt;id name="UserId" &gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;property name="UserName" /&gt; &lt;bag name="Ratings" generic="true" inverse="true" table="UserRating"&gt; &lt;key column="UserId" /&gt; &lt;one-to-many class="UserRating"/&gt; &lt;/bag&gt; &lt;/class&gt; &lt;class name="Item" &gt; &lt;id name="ItemId" &gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;property name="ItemName" /&gt; &lt;bag name="Ratings" generic="true" inverse="true" table="UserRating"&gt; &lt;key column="ItemId" /&gt; &lt;one-to-many class="UserRating"/&gt; &lt;/bag&gt; &lt;/class&gt; &lt;class name="UserRating" &gt; &lt;composite-id&gt; &lt;key-many-to-one class="User" column="UserId" name="User" /&gt; &lt;key-many-to-one class="Item" column="ItemId" name="Item" /&gt; &lt;/composite-id&gt; &lt;property name="Rating" /&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>I would suggest you look at the <a href="http://www.summerofnhibernate.com" rel="nofollow noreferrer">Summer of Nhibernate</a> screen cast as well as the <a href="http://www.autumnofagile.net/" rel="nofollow noreferrer">Autumn of Agile</a> series by Stephen Bohlen which gave me a great start with nhibernate.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload