我有以下课程
class MCustomer : DomanEntity
{
public MCustomer()
{
}
public virtual iCustomerEntity CustomerDetials { get; set; }
public virtual SolicitationPreferences SolicitationPreferences { get; set; }
}
public interface iCustomerEntity
{
Contact Contact { get; set; }
}
public class PersonEntity: DomanEntity, iCustomerEntity
{
public PersonEntity()
{
Intrests = new List<Intrest>();
Children = new List<PersonEntity>();
}
public virtual Contact Contact { get; set; }
public virtual DateTime BirthDate { get; set; }
public virtual IList<Intrest> Intrests { get; set; }
public virtual PersonEntity Spouse { get; set; }
public virtual IList<PersonEntity> Children { get; set; }
}
当我使用流畅的NHibernate AutoMapping时,我收到此错误:
NHibernate.MappingException:表MCustomer中的关联引用了一个未映射的类:Calyx.Core.Domain.CRM.iCustomerEntity
如何在我的域模型中设置具有接口类型的属性?
答案 0 :(得分:1)
我不认为你能做到这一点
当你试图加载你的MCustomer(session.Load<MCustomer>(id)
)时,NHibernate只会知道你想要获得具有iCustomerEntity的MCustomer。它不知道要使用哪个实现(PersonEntity或CoderEntity?)。它如何知道用于检索iCustomerEntity数据的映射?
答案 1 :(得分:0)
看起来像是对我的“任何”映射。你应该研究一下。据我所知,FNH还不支持。
答案 2 :(得分:0)
https://www.hibernate.org/hib_docs/nhibernate/html/inheritance.html
它是一种标准的Nhibernate模式。我正在尝试做同样的事情