Set .IncludeBase option for all abstract classes?

ThomasB's Avatar

ThomasB

07 Apr, 2010 05:20 PM via web

Hi!

First let me congratulate to that great piece of code, Fluent saves me relly a lot of cumbersome configuration time!

What I finally want to do now is to auto-map all abstract classes by default. That's because I have a 3 level inheritance strategy (table-per-subclass). l1 and l2 are always abstract, because nobody should be able to instantiate them. But of course I want to store their attributes too on my DB. So at the moment, for every new abstract l2 class I need to add another line of config code (.IncludeBase...).

Is there a possibility to add them all, something like .IncludeBase<*> ? :-)

Thanks, looking forward to your reply!

  1. 2 Posted by ThomasB on 13 Apr, 2010 12:18 PM

    ThomasB's Avatar

    Has really nobody an idea if this would be possible?

    I tried a bit with custom conventions but I'm not sure if my approach is the right one. I tried to use reflection to identifiy a classes abstract status, but it didn't work. Which convention interface could be used to inherit from (I tried with 'FluentNHibernate.Conventions.IClassConvention') :-(

  2. Support Staff 3 Posted by James Gregory on 16 May, 2010 05:40 PM

    James Gregory's Avatar

    Abstract classes are considered, by default, to be Layer Supertypes which is why we don't map them. As you know, you can use IncludeBase to explicitly override that decision. To do it on a larger scale, there's a configuration option called AbstractClassIsLayerSupertype which is used to determine whether an abstract class is a layer supertype.

    You can alter that configuration by overriding it in your own IAutomappingConfiguration instance, or by changing it in the Setup method.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What day comes after Monday?