title: Fluent NHibernate - Mapping a dictionary of component/value type objects as a HasMany
body: <p>I have a class, <code>Item</code> that has many <code>Rates</code>.  They are keyed by an enum, <code>RateType</code>.</p>
  
  <pre><code>public class Item
  {
      int Id {get;set;}
      IDictionary&lt;RateType, Rate&gt; Rates {get;set;}
      // some other stuff
  }
  
  public class Rate
  {
      RateType Type {get;set;}
      decimal Amount {get;set;}
      decimal Quantity {get;set;}
  }
  </code></pre>
  
  <p>I am overriding my mapping thusly:</p>
  
  <pre><code>public void Override(FluentNHibernate.Automapping.AutoMapping&lt;Item&gt; mapping)
  {
      mapping.HasMany(x =&gt; x.Rates)
          .AsMap(x =&gt; x.Type)
          .KeyColumns.Add("Item_Id")
          .Table("InvoiceItem_Rates")
          .Component(x =&gt; x.Map(r =&gt; r.Amount))
          .Component(x =&gt; x.Map(r =&gt; r.Quantity))
          .Cascade.AllDeleteOrphan()
          .Access.Property();
  }
  </code></pre>
  
  <p>This has two problems with it.</p>
  
  <p>1)  When I fetch an item, the <code>Type</code> is placed as the key of the Dictionary without problems.  However, it is not assigned to the <code>Type</code> property within the <code>Rate</code>.</p>
  
  <p>2)  I'm expecting three columns in the table <code>InvoiceItem_Rates</code> (<code>Item_Id</code>, <code>Type</code>, <code>Quantity</code>, and <code>Amount</code>.  However, <code>Amount</code> is suspiciously absent.</p>
  
  <p>Why are these things happening?  What am I doing wrong?</p>