【问题标题】:NHibernate mapping Dictionary by codeNHibernate 映射字典的代码
【发布时间】:2014-06-25 13:47:29
【问题描述】:

如何使用按代码映射来映射此字典:

public class User
{
    public virtual Dictionary<Option, bool> Options { get; set; } }
}

数据库如下所示:

User     UserOptions    Option
---      ---            ---
Id       Id             Id
         UserID
         OptionID
         bool_column

我尝试了该映射(查看here):

Map(x => x.Dictionary, 
m =>
{
    m.Key(k => k.Column("UserID"));
    m.Table("UserOptions");
},
k => k.ManyToMany(m =>
{
    m.Column("OptionID");
}),
v => v.Element(m => 
{
    m.Column("bool_column");
})
);

但是有一个错误: An association from the table UserOptions refers to an unmapped class: System.Boolean

【问题讨论】:

标签: nhibernate nhibernate-mapping-by-code


【解决方案1】:

好的,我是bug

通过对User使用xml-mapping,并添加configuration.AddXmlFile("Mappings/User.hbm.xml");解决

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-17
    • 1970-01-01
    • 2014-04-02
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    相关资源
    最近更新 更多