我正在使用NHibernate,我直接用属性映射我的对象。我见过类似的问题,但大多数情况下人们使用映射文件......或者他们给出了不再存在的链接的答案:)对于下面的类,我必须为属性表添加哪些属性表一个IDictionary?我想这就像[Map],但有哪些属性和/或元素?我在哪里可以找到一些文件?
[Class(Table = "SpecificitySets", Name = "ZslSpecificityTable")]
public class SpecificityTable
{
[Id(0, TypeType = typeof(ulong), Name = "Id")]
[Generator(1, Class = "native")]
public uint Id
[Map(Name = "specificityMapping", Table = "SpecificityMapping")]
// and then ??
public virtual IDictionary<string, double> Table { get; private set; }
// ...
}
答案 0 :(得分:3)
[Class(Table = "SpecificitySets", Name = "ZslSpecificityTable")]
public class SpecificityTable
{
[Id(0, TypeType = typeof(ulong), Name = "Id")]
[Generator(1, Class = "native")]
public uint Id
[Map(1, Name = "Table", Table = "SpecificityMapping")]
[Key(1, Column = "SpecTableId")]
[Index(3, Column = "Term", Type="string")]
[Element(4, Column = "Value", Type="double")]
public virtual IDictionary<string, double> Table { get; private set; }
// ...
}
1
答案 1 :(得分:1)
你可能不会喜欢这个答案,但是...使用NHibernate.Mapping.Attributes它不推荐。
XML文件是最灵活和最有文档记录的方法,FluentNHibernate是另一种选择,ConfORM是一种完全不同的方式来查看它。