【问题标题】:Fluent Nhibernate and pluggable inheritance流畅的 Nhibernate 和可插入的继承
【发布时间】:2009-03-21 21:06:49
【问题描述】:

有没有什么方法可以在不改变 Fluent NHibernate 的基表映射的情况下定义/扩展继承?例如使用 Castle.ActiveRecord(基于 NHibernate),您可以像这样定义继承:

[ActiveRecord("entity"), JoinedBase]
public class Entity : ActiveRecordBase
{ 
    [PrimaryKey]
    public int Id { get; set; }
}

[ActiveRecord("entitycompany")]
public class CompanyEntity : Entity
{
    [JoinedKey("comp_id")]
    public int CompId { get; set; }
}
  • 可以在不更改基本实体映射的情况下添加或删除新子类。
  • 当我们调用 Entity.FindAll() 时,它会返回所有实体(包括继承的实体)。

【问题讨论】:

    标签: c# inheritance nhibernate fluent


    【解决方案1】:

    现在不行,不。当然不需要以任何方式修改您的父类映射。

    【讨论】:

      【解决方案2】:

      好的,我找到了方法,可以通过使用 IClassConvention + IOC(带有程序集扫描的结构映射)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多