I have the following domain model to map using ClassMaps/SubclassMaps
A - HasMany -> B (A should be table)
B is abstract in code (and should not be a table)
C,D,E inherits B and all have very different properties. Each of them should be a table with foreign key to A.
I get the tables I want, but I cannot see how to map HasMany
from entity A that has one property IList<B> SomeProperty
I would like to define in ClassMap<A>
that SomeProperty
cascades on C,D,E
This obviously doesn't work, in ClassMap<A>
:
HasMany<C>(x => x.B).Cascade.All();
HasMany<D>(x => x.B).Cascade.All();
HasMany<E>(x => x.B).Cascade.All();
As I cannot duplicate B.
Example:
public class Person
{
public virtual IList<Animal> Animals { get; set; }
public void AddAnimal(Animal animal)
{
Animals.Add(animal);
}
}
public abstract class Animal
{
//some common properties
}
public class Cat : Animal
{
//some cat properties
}
public class Horse : Animal
{
//some horse properties
}
In this case I would like ClassMap<Person>
to map to Cat and Horse over the abstract class Animal.