有什么方法可以在不使用 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()
它时,它会返回所有实体(也包括继承的实体)。