So everything is working well with the basic discriminator mapping. I can interact directly with entities A and B without any problems.
public class BaseType {}
public class EntityA : BaseType {}
public class EntityB : BaseType {}
This maps without drama in the BaseType mapping as
DiscriminateSubClassesOnColumn<string>("Type")
.SubClass<BaseType>("A", m => { })
.SubClass<BaseType>("B", m => { });
The problem occurs when: in an aggregate we want to map collections to each subclass
Using mapping like below
public class AggregateMap: BaseMap<Aggregate>
{
public AggregateMap()
{
HasMany<EntityA>(x => x.ACollection).AsSet().Cascade.All();
HasMany<EntityB>(x => x.BCollection).AsSet().Cascade.All();
}
}
These obviously arent full mappings but are the minimum amount to descibe what I am attempting. Items added to ACollection and BCollection are persisted correctly through the cascading when Aggregate is saved. However, when aggregate is retrieved there is confusion on the type discrimination.
I have run through so many different possible solutions I no longer know what didn't work. I feel that I shouldn't have to provide a where clause on the collections but things just aren't working for me.
Any clues would be appreciated.