Skip to end of metadata
Go to start of metadata

In the current version of Neo you cannot make one entity inherit from another. However, there are a few things you can do which are often sufficient:

1) You can have your entities inherit from an arbitrary base class on a per entity basis. So, if you have, for example, a StandardShipping entity and an ExpressShipping entity that share some properties and derived properties you could create an AbstractShippingBase class that declares the properties as abstract and implements the shared derived properties. Now, in the model you set the base class for StandardShipping and ExpressShipping to AbstractShippingBase.

2) You can, within some limits, change the class that is instantiated for a given entity. Normally, one works with the ObjectType property on EntityMap but it actually uses the ConcreteObjectType property to determine what type to create. Using the default template ConcreteObjectType just returns ObjectType but that's open to customisation.

3) Similar to the above, EntityMap provides another, more powerful, hook to influence object creation: In your templates you can override the CreateInstance() method which receives the row an context. So, if you simply declare the class to be Employee in your model you could have your custom code inspect the data in the row and then create a PartTimeEmployee or a FullTimeEmployee, both of which would have to be normal C# classes (or VB if you want!) that inherit from Employee.

Labels: