public class PersistedData
{
public virtual IDictionary<key, value> Dictionary { get; set; }
}
public class PersistedDataMap : ClassMap<PersistedData>
{
HasMany(x => x.Dictionary)
.Table("dict_table")
.KeyColumn("column_id")
.AsMap<string>("key")
.Element("value");
}
This will correctly map Dictionaryto the table dict_tableand use column_idto associate it with the base id.
As a side note, if you want to use Enum as a key in a dictionary, it should be noted that it NHibernate.Type.EnumStringType<MyEnum>can be used instead of a string in .AsMap<string>to use a string value instead of an Ordinal.
source
share