views:

303

answers:

1

I have a base class, which has 2 derived class.

Each derived class has a mapping file (they base class has non and it's abstract)

Each derived class has an object that points to itself (which is defined in the base class);

class Base
{
   Base myManager;
}
class Derived1 : Base
{

}

Class Derived2 : Base
{
}

for each derived class there is a mapping:

Map(x=>x.myManager, "ManagerID");

But Fluent can't Create SessionFactory, as x.myManager points to an unmapped class (Base)

I don't want to use Derived1 myManager and Derived2 myManager in the derived classes, as other classes that use these classes only knows about the properties of the base class.

Any Idea how to resolve this situation ?

+1  A: 

You will need to create a mapping for the base class:

public class BaseMap : ClassMap<Base>
{
    public BaseMap()
    {
        References(x => x.myManager, "ManagerID");
    }
}

and then map the other classes as subclasses:

public class Derived1Map : SubclassMap<Derived1>
{
    public Derived1Map ()
    {
        // other mapping here...
    }
}
David M