title: how to map to a SortedList in NHibernate
body: <p>I have an nHibernate parent child table relationship.  The parent class is currently pulling the children into a List but I want to put them in a SortedList based on an ordering column in the table.  How do I change the NHibernate mapping file to let the system know which column I am ordering on?</p>
  
  <p>The current NHibernate mapping files are:</p>
  
  <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                     namespace="Model.Configuration.Pages"
                     assembly="Model.Configuration"&gt;
    &lt;joined-subclass
              table="PageConfigurations"
              name="PageConfiguration"
              extends="Model.Configuration.Configuration.TargetedConfiguration"
              lazy="false"&gt;
      &lt;key column="TargetedConfigurationId" /&gt;
  
      &lt;property name="SchemaVersion" /&gt;
  
      &lt;property name="Template" type="System.String" length="50" /&gt;
  
      &lt;property name="PageKey" type="System.String" length="50" /&gt;
  
      &lt;property name="Percentage" /&gt;
  
      &lt;bag name="Controls" cascade="all-delete-orphan" lazy="false" &gt;
        &lt;key column="PageConfigurationId" /&gt;
        &lt;one-to-many class="WidgetConfiguration"/&gt;
      &lt;/bag&gt;
  
    &lt;/joined-subclass&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>for the parent table and:</p>
  
  <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                     namespace="Model.Configuration.Pages"
                     assembly="Model.Configuration"&gt;
    &lt;class name="WidgetConfiguration" lazy="false" table="PageConfiguration_Widgets" discriminator-value="Default"&gt;
      &lt;id name="Id"  unsaved-value="0" type="int" &gt;
        &lt;generator class="identity" /&gt;
      &lt;/id&gt;
      &lt;discriminator column="ConfigurationType" /&gt;
  
      &lt;property name="Slot" type="System.String" length="100" /&gt;
      &lt;property name="WidgetTypeName" type="System.String" length="100"/&gt;
      &lt;property name="ViewName" type="System.String" length="50" /&gt;
      &lt;property name="SlotOrder" type="System.Int32" /&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>for the child table.</p>
  
  <p>What do I need to add to the parent or child mappings to let them know that the new SlotOrder column should be used as the key field when fetching the WidgetConfiguration into a SortedList.</p>
  
  <p>EDIT: The class that the data is being read into is:</p>
  
  <pre><code>public class PageConfiguration : TargetedConfiguration 
  {
  
      public PageConfiguration()
      {
          // replaced by SortedList
          //Controls = new List&lt;WidgetConfiguration&gt;();
          Controls = new SortedList&lt;int, WidgetConfiguration&gt;();
      }
  
      public string PageKey { get; set; }
      public string Template { get; set; }
      public int? Percentage { get; set; }
      // replaced by SortedList
      //public IList&lt;WidgetConfiguration&gt; Controls { get; set; }
      public IDictionary&lt;int, WidgetConfiguration&gt; Controls { get; set; }
      public int SchemaVersion { get; set; }
  }
  </code></pre>
  
  <p>Notice that the <code>List&lt;WidgetConfiguration&gt;</code> has been changed to <code>SortedList&lt;int, WidgetConfiguration&gt;</code>.  How do I tell NHibernate that when a new item is added to the SortedList that the key value used should be WidgetConfiguration.SlotOrder?</p>