Data Access has been discontinued. Please refer to this page for more information.

InheritanceMappingAttribute

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

Use InheritanceMappingAttribute attribute to map an inheritance hierarchy. One InheritanceMappingAttribute is specified per mapped class.

The InheritanceMappingAttribute attribute exposes the following properties:

  • DiscriminatorValue - represents the discriminator value in a mapped inheritance hierarchy. The discriminator column defines which row in the database to which type in the persistent model belongs to. This is only necessary if the type is part of a class hierarchy. For correct materialization, discriminator values must be unique and should match the values in the database. A row with a discriminator code value that does not exactly match (even by casing) instantiates the class by using IsDefault set to true.
  • IsDefault - sets whether an object of this type is instantiated when the discriminator value does not match a specified value.
  • InheritanceStrategy - sets the inheritance strategy. Currently Telerik Data Access supports three types of inheritance strategies - Flat, Horizontal and Vertical. At the Flat inheritance strategy, all classes share a single table. In this case Discriminator column is required for the complete definition. When Vertical is used, then each type has its own table. The table contains only the members defined for the respective type. The root base type table must contain a discriminator column. The Horizontal inheritance strategy requires that each type has its own table. As the base types should be abstract, they will not have tables mapped to them and every concrete type will have columns that contain base class fields information.

In the following code example, Person is defined as the root class and Customer derives from it.

[Table("Persons")]
public class Person
{
}
[Table("Customers")]
[InheritanceMapping(InheritanceStrategy = InheritanceStrategy.Vertical)]
public class Customer : Person
{
}
<Table("Persons")>
Public Class Person
End Class
<Table("Customers"), InheritanceMapping(InheritanceStrategy := InheritanceStrategy.Vertical)>
Public Class Customer
 Inherits Person
End Class