c# - 我应该在类里面使用哪个 NHibernate.Mapping.Attributes 来映射字典?

标签 c# nhibernate dictionary

我正在使用 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/

相关文章:

C#:由列表索引的字典

c# - 使用 Microsoft.ServiceBus.Messaging.MessageSession 许多消息 Complete()、Abort() 等

c# - 如何在 ASP.NET WebForms 应用程序中处理 NHibernate session ?

c# - 将 CSS 类添加到 TagHelper 中的 html 元素

c# - 使用 HAVING COUNT 对 NHibernate 的 SQL 查询

nhibernate - 我在哪里可以下载 nhibernate.caches.syscache 3.1

python - 使用 itemgetter() 方法根据元组的第二个值在字典中查找键值对

python - 如何通过指定值范围从字典中提取数据?

java - 按值对 Map<Key, Value> 进行排序

c# - Puppeteer Sharp html 到 pdf 并启用链接