假设我有一类SomeClass的,有一个查找字典: DataDictionary;
Assume I have a class "SomeClass" that has a lookup dictionary: DataDictionary;
我目前在SomeClass.hbm.xml一个这样的映射:
I currently have a mapping in SomeClass.hbm.xml like this:
<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)在code映射。我将如何映射上面的字典属性?
I want to use NHibernate's new (version 3.2) By Code mappings. How would I map the dictionary property above?
目前我有:
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");
});
}
}
晴我在对于如何指定索引的等效和为一个字典映射的元素的损失。
Mostly I am at a loss for how to specify the equivalent of the index and the element for a dictionary mapping.
字典映射的每个部分都需要一个单独的委托:
Each part of the dictionary mapping requires a separate delegate:
Map(x => x.DictionaryProperty,
mapping =>
{
mapping.Key(k => k.Column("SomeClassID"));
mapping.Table("SomeClassData");
},
mapping => mapping.Element(k => k.Column("Key")),
mapping => mapping.Element(k => k.Column("Value")));
第一个元素
是地图键
(首页
是过时的地图
),而第二个是元素
。
The first Element
is the map-key
(index
is obsolete for map
), and the second one is the element
.
上一篇:如何添加应用程序到&QUOT;分享这个地方&QUOT;列表中的谷歌地图这个地方、应用程序、地图、列表中
下一篇:Android的:如何使用异步下载一个PNG文件并将其设置为ImageView的?设置为、如何使用、文件、并将其