I have a very extensible and modular application. I want to extend the displayed Entites from other assemblies. However, I still need to work with the base classes.
Example:
Mapping the parent class in assembly A:
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
Table("Persons");
Id(x => x.Id).GeneratedBy.Assigned();
}
}
Mapping child classes in assembly B:
public class EmployeeMap : SubclassMap<Employee>
{
public EmployeeMap()
{
Table("Persons");
Extends(typeof(Person));
KeyColumn("Id");
LazyLoad();
HasMany<Assignments>(x => x.Assignments).KeyColumn("Id").Inverse().Cascade.AllDeleteOrphan().LazyLoad().NotFound.Ignore();
}
}
Now, when I create Person in some Assembly A code, it is saved as NHibernate's Employee. And this leads to the exclusion of the cast class due to proxying whenever I save Person and try to update it in Assembly A. Assembly A should not have a dependency on assembly B.
I need to work with the parent class in all assembly methods A. The child class is used only in other assemblies.
- ? NHibernate ? SaveOrUpdate ; ? NHibernate ? ?
, ! - .
! , . ?