What is the best way of mapping a simple Dictionary property using Fluent NHibernate?
Using a simple class relationship such as the following:
public class Foo {
public virtual IDictionary Bars { get; set; }
}
public class Bar {
public virtual string Type { get; set; }
public virtual int Value { get; set; }
}
You can map this with Fluent NHibernate in this way:
mapping.HasMany(x => x.Bars)
.AsMap(x => x.Type);
Where Bar.Type is used as the key field into the dictionary.