我正在使用 NHibernate,我直接使用属性映射我的对象。我见过类似的问题,但大多数情况下人们使用映射文件......或者他们用不再存在的链接给出答案:)对于以下类,我必须为属性表添加哪些属性字典?我想它类似于 [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; }
// ...
}
最佳答案
经过一些尝试,其实并没有那么难:
[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
关于c# - 我应该在类里面使用哪个 NHibernate.Mapping.Attributes 来映射字典?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2500883/