如何在 S#arp 架构中自动映射每个类的表层次结构

发布于 2024-08-18 17:44:35 字数 1063 浏览 1 评论 0原文

我对 S#harp 架构和流利的 nhibernate 非常陌生。我试图使用模板构建示例解决方案。 当我尝试为以下域运行 MappingIntegrationTest 时,它失败了

public class Component
{
  public virtual string comp { get; set; }
}

public class Parent : Entity
{
   public virtual string Type { get; set; }
}

public class Child1: Parent
{
   public virtual Component Blah { get; set }
}

ParentMap 如下所示:

public class ParentMap : IAutoMappingOverride<Parent>
{
    public void Override(AutoMapping<Parent> mapping)
    {
        mapping.DiscriminateSubClassesOnColumn("Type")
            .SubClass<Child1>(m =>
                            {
                               m.Component(c => c.Blah, c =>
                                    {
                                        c.Map(x => x.comp , "comp");
                                    }
                            }
    }
}

映射集成测试对我来说失败 * 数据库不是通过数据库方法配置的。

----> NHibernate.MappingException :Parent 表中的关联引用了未映射的类:Component

我需要从 AutoMapper 中删除这些类吗?

I am pretty new to S#harp architecture and fluent nhibernate. I was trying to build a sample solution using the template.
MappingIntegrationTest fails for me when I try to run it for the following domains

public class Component
{
  public virtual string comp { get; set; }
}

public class Parent : Entity
{
   public virtual string Type { get; set; }
}

public class Child1: Parent
{
   public virtual Component Blah { get; set }
}

The ParentMap looks like following:

public class ParentMap : IAutoMappingOverride<Parent>
{
    public void Override(AutoMapping<Parent> mapping)
    {
        mapping.DiscriminateSubClassesOnColumn("Type")
            .SubClass<Child1>(m =>
                            {
                               m.Component(c => c.Blah, c =>
                                    {
                                        c.Map(x => x.comp , "comp");
                                    }
                            }
    }
}

The mapping integration tests fail for me
* Database was not configured through Database method.

----> NHibernate.MappingException : An association from the table Parent refers to an unmapped class: Component

Do I need to remove these classes from AutoMapper?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文