1

I'm using the Fluent NHibernate mapper with table-per-subclass to map the following structure:

public abstract class A
{
    // properties here
}

public abstract class B : A
{
    // methods here
}

public class C : B
{
    // properties here
}

My database only has tables to represent class A and class C. Class B exists only in my model for my convenience and doesn't contain any properties that needs to be mapped.

How can I get the automapper to skip B and map C as a subclass of A?

Daniel Schilling
  • 4,829
  • 28
  • 60
David Pfeffer
  • 38,869
  • 30
  • 127
  • 202

1 Answers1

2

The Fluent NHibernate wiki has a section on ignoring base types when automapping that might be worth reading.

James Gregory
  • 14,173
  • 2
  • 42
  • 60
  • If you skip the intermediate subclass with IgnoreBase as the wiki article suggests, then believes class `C` is an independent class unrelated to `A`. – David Pfeffer Feb 18 '10 at 16:10
  • Ah, bummer. That'll be a bug then. I've created an issue for you to track: http://fluentnhibernate.lighthouseapp.com/projects/33236-core/tickets/128-skip-intermediary-classes-when-automapping-subclasses. – James Gregory Feb 19 '10 at 09:08
  • Links are dead. I think this is the current version: https://github.com/nhibernate/fluent-nhibernate/wiki/Auto-mapping-generic-base-classes – Erik Knowles Jun 07 '23 at 23:13