nhibernate 不从程序集中获取映射

发布于 2024-08-01 18:10:07 字数 1297 浏览 4 评论 0原文

我正在使用 fnh 和 castle nhib 设施。

我在这里遵循了迈克·哈德洛的建议: http://mikehadlow .blogspot.com/2009/01/integrating- Fluent-nhibernate-and.html

这是我的 FluentNHibernateConfigurationBuilder:

public Configuration GetConfiguration(IConfiguration facilityConfiguration)
    {
        var defaultConfigurationBuilder = new DefaultConfigurationBuilder();
        var configuration = defaultConfigurationBuilder.GetConfiguration(facilityConfiguration);

        configuration.AddMappingsFromAssembly(typeof(User).Assembly);

        return configuration;

    }

我知道该工具正在拾取它,因为我可以突破该方法并逐步执行。

但是,完成后,不会创建任何映射,并且当我尝试保存实体时出现以下错误:

没有持久化:IsItGd.Model.Entities.User

这是我的用户类:

//simple model of web user
public class User
{

    public virtual int Id { get; set; }

    public virtual string FullName { get; set; }

}

这是映射:

 public class UserMap : ClassMap<User>
{
    public UserMap() {

        Id(x=>x.Id);
        Map(x=>x.FullName);
    }
}

i实在看不出问题所在。 奇怪的是 - 如果我使用自动映射,它会拾取所有内容 - 但我不想使用自动映射,因为在这种情况下我无法做某些事情。

有什么线索吗?

w://

I'm using fnh and castle nhib facility.

I followed the advice from mike hadlow here: http://mikehadlow.blogspot.com/2009/01/integrating-fluent-nhibernate-and.html

here is my FluentNHibernateConfigurationBuilder:

public Configuration GetConfiguration(IConfiguration facilityConfiguration)
    {
        var defaultConfigurationBuilder = new DefaultConfigurationBuilder();
        var configuration = defaultConfigurationBuilder.GetConfiguration(facilityConfiguration);

        configuration.AddMappingsFromAssembly(typeof(User).Assembly);

        return configuration;

    }

i know the facility is picking it up as i can break inside that method and it steps through.

however, when it's done, non of the mappings are created and i get the following error when i try to save an entity:

No persister for: IsItGd.Model.Entities.User

here is my user class:

//simple model of web user
public class User
{

    public virtual int Id { get; set; }

    public virtual string FullName { get; set; }

}

and here is the mapping:

 public class UserMap : ClassMap<User>
{
    public UserMap() {

        Id(x=>x.Id);
        Map(x=>x.FullName);
    }
}

i really can't see what the problem is. the strange thing is - is that if i use automapping it picks everything up - but i don't want to use automapping as i can't do certain things in that scenario.

any clues?

w://

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

会发光的星星闪亮亮i 2024-08-08 18:10:07

此问题已修复 - 这是 fnh 中的一个错误:(

this has been fixed - it was a bug in fnh :(

感性 2024-08-08 18:10:07

您的映射文件是否与域类位于同一程序集中? 否则,在指定要查找的程序集时,您可能希望使用 UserMap 而不是 User:

configuration.AddMappingsFromAssembly(typeof(UserMap).Assembly);

Are your mapping files located in the same assembly as you domain classes? Otherwise you might want to use UserMap instead of User when specifying the assembly to look in:

configuration.AddMappingsFromAssembly(typeof(UserMap).Assembly);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文