I have an Item class that has many Rates . They are associated with the listing, RateType .
public class Item { int Id {get;set;} IDictionary<RateType, Rate> Rates {get;set;} // some other stuff } public class Rate { RateType Type {get;set;} decimal Amount {get;set;} decimal Quantity {get;set;} }
I redefine my mapping like this:
public void Override(FluentNHibernate.Automapping.AutoMapping<Item> mapping) { mapping.HasMany(x => x.Rates) .AsMap(x => x.Type) .KeyColumns.Add("Item_Id") .Table("InvoiceItem_Rates") .Component(x => x.Map(r => r.Amount)) .Component(x => x.Map(r => r.Quantity)) .Cascade.AllDeleteOrphan() .Access.Property(); }
This has two problems.
1) When I take an element, Type is placed as the key of the Dictionary without problems. However, it is not assigned to the Type property within Rate .
2) I expect three columns in the InvoiceItem_Rates table ( Item_Id , Type , Quantity and Amount . However, Amount suspiciously missing.
Why is all this happening? What am I doing wrong?
source share