I have an abstract entity base class defined like this:
public abstract class SessionItem : Entity
{
public virtual Session Session { get; set; }
}
In addition, I'm using auto mapping:
private AutoPersistenceModel CreateAutomappings()
{
return AutoMap
// configuration
.Conventions.Add(DefaultCascade.All())
// more configuration
}
SessionItem
has several derived classes/tables, and I'd like to override the cascading policy for all of them. I tried the following:
public class SessionItemAutommapingOverride : IAutoMappingOverride<SessionItem>
{
public void Override(AutoMapping<SessionItem> mapping)
{
mapping.References(x => x.Session).Cascade.None();
}
}
But unfortunately the override is not called since SessionItem
is abstract (and is not mapped). I prefer to avoid overriding it for each subclass (using IAutoMappingOverride).
Is there any way to override cascading for multiple types, without using IAutoMappingOverride<> for each one?