I have C# classes that use Inheritance on the server side of a Web API. The base/super class has some 'one two many' navigation properties that are common to all the inherited classes. These classes are not EF or NH classes.
Breeze correctly generates the base class and inherited classes in the metadata and correctly shows the navigation properties from the base class on the inherited classes.
When loading the data from the API, breeze correctly "links" the "Child" -> "Parent" side of the linked navigation property, but does not map the reverse "Parent" -> "Child" relationship on the base class.
If I move the navigation property to the inherited child class, out of the base/super class then Breeze correctly links all the relationships from the Parent to the Child and the Child to the Parent.
public class Fine
{
public int Id { get; set; } // Primary Key
public int VehicleId {get; set; } // Foreign Key
public decimal Amount { get; set; }
... etc
}
public class Vehicle
{
public int Id { get; set; } //Primary Key
... other common properties
public IList<Fine> Fines { get; set; } // Common nav property
}
public class Motorcycle
{
public string MudguardColour { get; set; }
... other specific properties
}
public class MotorVehicle
{
public string BumperColour { get; set; }
... other specific properties
}
Breeze creates the entities on the client side that correctly reflects the shapes above and has ko.observable as well as ko.observablearray for the one to many (Vehicle -> Fines) properties.
If I query the server for the list of MotorVehicles and MotorCycles first, all is well. I then query the list for fines separately and breeze correctly links the "Fines" that are related to a specific Vehicle correctly. I can the say "fine.motorVehicle.id" or "fine.motorCycle.id", depending on the type and get the base/super class properties, like Id as well.
Breeze however does not link the "vehicle.fines", "motorVehicle.fines" nor the "motorCycle.fines" navigation properties. They remain empty arrays even though the "fine" entity is linked correctly to the vehicle, motorVehicle and motorCycle entities.
If I move the navigation property to to the child/inherited class, then breeze correctly links the entities as expected.
public class Fine
{
public int Id { get; set; } // Primary Key
public int VehicleId {get; set; } // Foreign Key
public decimal Amount { get; set; }
... etc
}
public class Vehicle
{
public int Id { get; set; } //Primary Key
... other common properties
//public IList<Fine> Fines { get; set; } // Common nav property
}
public class Motorcycle
{
public string MudguardColour { get; set; }
... other specific properties
public IList<Fine> Fines { get; set; } // Common nav property now in child class
}
public class MotorVehicle
{
public string BumperColour { get; set; }
... other specific properties
}
This gives me "fine.vehicle.id", "fine.motorVehicle.bumperColour" and "fine.MotorCycle.mudguardColour" as well as parent -> child relationship "vehicle.fines[0].amount and "motorCycle.fines[0].amount".
How do I get breeze to set these navigation properties when they are on the base/super class to avoid repeating them on the child/inherited classes?
PS: I am not using EF nor NH, but my metadata is modelled based on the NH layout (from the breeze NH samples) as well as the Breeze documentation with the required foreign keys related etc.
PPS: All of this works 100% for normal classes that do not use the inheritance setup.
Hope I have explained sufficiently?