Any use of nHibernate with a Domain object and a DTO object implemented from a common interface? I am trying to separate all of my nHibernate attributes in a Domain object, leaving my DTO and interface clean.
The problem is related to nHibernate metadata errors when it tries to associate interfaces with specific classes.
NHibernate.MappingException: association links: unmapped class: IContact
I understand why he complains about using a non-hibernated interface, but I'm trying my best to visualize the way restructuring around him. The skeletal reproduction of my code is outlined below, any ideas on how to better structure my code?
public interface ICompany
{
IList<IContact> Contacts { get; set; }
}
public class CompanyDTO : ICompany
{
private IList<IContact> contacts;
public IList<IContact> Contacts { get { return this.contacts; } set { this.contacts = value; } }
}
[ActiveRecord]
public class Company : ActiveRecordBase<Company>, ICompany
{
private IList<IContact> contacts;
[HasMany(Inverse=true, Table="Contact", ColumnKey="CompanyId")]
[ScriptIgnore]
public IList<IContact> Contacts { get { return this.contacts; } set { this.contacts = value; } }
}
Edit:
, , (.. , ). DTO , .
, alex , ICompany Contacts IList, IList. IContact, DTO Contact Domain.