假设我有一个类“SomeClass”,它有一个查找字典:DataDictionary;
我目前在 SomeClass.hbm.xml 中有一个映射,如下所示:
<class name="SomeClass>
<id name="ID" type="System.Guid">
<generator class="guid" />
</id>
<map name="DictionaryProperty" table="SomeClass_Data">
<key column="SomeClassID" />
<index column="Key" type="System.String" />
<element column="Value" type="System.String" />
</map>
</class>
我想使用 NHibernate 的新(3.2 版)按代码映射。我将如何映射上面的字典属性?
目前我有:
public class SomeClassMap :ClassMap<SomeClass>
{
public SomeClassMap()
{
Id(x => x.ID, mapping => mapping.Generator(Generators.Guid));
Map(x = x.DictionaryProperty, mapping =>
{
mapping.Key(k => k.Column("SomeClassID"));
mapping.Table("SomeClassData");
});
}
}
大多数情况下,我不知道如何为字典映射指定索引和元素的等效项。