Currently, I am using the following code to ignore base types with Fluent NHibernate automapping:
AutoMap.AssemblyOf<Class1>(new MyDefaultAutomappingConfiguration())
.Conventions.Setup(GetConventions())
.IgnoreBase<MyCore.BaseTypes.AmazingBaseType>()
.IgnoreBase<MyCore.BaseTypes.AnotherAmazingBaseType>()
.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
Is there a way to ignore base types by a namespace (i.e. MyCore.BaseTypes
) instead of having to use the IgnoreBase()
method for every base type I have?
I tried accomplishing this using my overriden ShouldMap(Type)
method in DefaultAutomappingConfiguration
-extended class (i.e. MyDefaultAutomappingConfiguration
) to accomplish this but it still tried to map the base types:
public class MyDefaultAutomappingConfiguration: DefaultAutomappingConfiguration {
public override bool ShouldMap(Type type) {
return !IsBaseType(type);
}
private bool IsBaseType(Type type) {
return type.Namespace == typeof(MyCore.BaseTypes).Namespace;
}
}