I have the following class
我有以下课程
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; }
}
When I use fluent NHibernate AutoMapping I receive this error:
当我使用流畅的NHibernate AutoMapping时,我收到此错误:
NHibernate.MappingException: An association from the table MCustomer refers to an unmapped class: Calyx.Core.Domain.CRM.iCustomerEntity
NHibernate.MappingException:表MCustomer中的关联引用了一个未映射的类:Calyx.Core.Domain.CRM.iCustomerEntity
How do I set up a property in my domain model that has an Interface type?
如何在我的域模型中设置具有接口类型的属性?
3 个解决方案
#1
https://www.hibernate.org/hib_docs/nhibernate/html/inheritance.html
Its a standard Nhibernate pattern. I'm trying to do the same thing
它是标准的Nhibernate模式。我正在尝试做同样的事情
#2
I don't think, that you can do that.
When you would try to load your MCustomer (session.Load<MCustomer>(id)
), NHibernate would only know, that you want to get MCustomer, that has an iCustomerEntity. It would not know which implementation (PersonEntity or CoderEntity?) to use. How would it know which mapping to use to retrieve the data for iCustomerEntity?
我不认为你能做到这一点。当您尝试加载MCustomer(session.Load
#3
Looks like a "any" mapping to me. You should look into that. And as far as I can see FNH does not support that yet.
看起来像是对我的“任何”映射。你应该研究一下。据我所知,FNH还不支持。
#1
https://www.hibernate.org/hib_docs/nhibernate/html/inheritance.html
Its a standard Nhibernate pattern. I'm trying to do the same thing
它是标准的Nhibernate模式。我正在尝试做同样的事情
#2
I don't think, that you can do that.
When you would try to load your MCustomer (session.Load<MCustomer>(id)
), NHibernate would only know, that you want to get MCustomer, that has an iCustomerEntity. It would not know which implementation (PersonEntity or CoderEntity?) to use. How would it know which mapping to use to retrieve the data for iCustomerEntity?
我不认为你能做到这一点。当您尝试加载MCustomer(session.Load
#3
Looks like a "any" mapping to me. You should look into that. And as far as I can see FNH does not support that yet.
看起来像是对我的“任何”映射。你应该研究一下。据我所知,FNH还不支持。