title: NHibernate composite-element mapping-by-code
body: <p>I'm trying to learn NHibernate mapping by code by translating the examples in 'NHibernate in Action' and I'm having a problem with one of the examples.  I've inlcuded the the XML that I'm trying to translate and my effort at translating it.  The code basically has a many to many relationship between a category and an item.  It uses a component class named CategorizedItem to maintain the relationship between the two entities.  </p>
  
  <p>The problem that I'm having is that once I declare the Items property of the Category in the lambda, the Item Class's properties are the only ones available for selection in the component mapping.  I'm wanting to let the mapping know that the CategorizedItem's properties are those to be mapped in the relationship, but I'm at a loss as to how this is achieved.  Below is the XML that I'm trying to translate...</p>
  
  <pre><code>&lt;set name="Items" table="CATEGORY_ITEM" lazy="true" &gt;
    &lt;key column="CATEGORY_ID"/&gt;
    &lt;composite-element class="CategorizedItem"&gt;
      &lt;parent name="Category"/&gt;
      &lt;many-to-one name="Item" class="Item" column="ITEM_ID" not-null="true"/&gt;
      &lt;many-to-one name="User" class="User" column="USER_ID" not-null="true"/&gt;
      &lt;property name="DateAdded" column="DATE_ADDED" not-null="true"/&gt;
    &lt;/composite-element&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>... and here is the mapping that I've partially done.</p>
  
  <pre><code>Set(
      category =&gt; category.Items,
      map =&gt;
      {
        map.Key(key =&gt;
          {
            key.Column("CATEGORY_ID");
  
          });
        map.Table("CATEGORY_ITEM");
        map.Lazy(CollectionLazy.Lazy);
      },
      r =&gt; r.Component(m =&gt;
      {
        m.Class
  
      })
    );
  </code></pre>
  
  <p>The class property of the component looks like the likely target, but it is rejecting CategorizedItem as the type parameter.  Any help would be greatly appreciated.</p>