How to map inheritance with property returned other inheritance?

Posted by dario-g on Stack Overflow See other posts from Stack Overflow or by dario-g
Published on 2010-06-09T20:15:21Z Indexed on 2010/06/09 21:12 UTC
Read the original article Hit count: 160

Hi
I have abstract class Vehicle and two classes that derive from: Car and ForkLift.

public abstract class Vehicle
{
    public EngineBase Engine { get; set; } 
}

public class Car : Vehicle
{
    public GasEngine Engine { get; set; }
}

public class ForkLift : Vehicle
{
    public ElectricEngine Engine { get; set; }
}

and Engine clasess:

public abstract class Engine
{
}

public class GasEngine : Engine
{
}

public class ElectricEngine : Engine
{
}

Engines are mapped with "table per class hierarchy". With Vehicles I want to use the same pattern.

How to map Engine class and derived with that Engine property?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about inheritance