C# – Automap a property whose type is Interface

cfluent-nhibernatenhibernate

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.MappingException: An association from the table MCustomer refers to an unmapped class: Calyx.Core.Domain.CRM.iCustomerEntity

How do I set up a property in my domain model that has an Interface type?

Best Answer

https://www.hibernate.org/hib_docs/nhibernate/html/inheritance.html

Its a standard Nhibernate pattern. I'm trying to do the same thing

Related Topic