The LINQ to SQL Converter allows you to convert LINQ to SQL models with inheritance hierarchies. The purpose of this topic is to introduce you the most specific remarks about the inheritance conversion.
LINQ to SQL supports only Flat Inheritance (Table per Hierarchy) strategy. This means that all levels in the inheritance hierarchy are stored in the same table, and a discriminator column specifies which rows for which classes are.
Consider the sample inheritance hierarchy shown on the image below:
The entire hierarchy is stored in a single table.
For successful conversion, the following requirements should be met:
- The inheritance should be defined by using the LINQ to SQL Designer.
- A discriminator property should be defined (in this example this is voa_class).
- Discriminator values for each of the classes in the hierarchy should be specified.
- You could specify Inheritance Modifier, it will be converted to the corresponding modifier in the Telerik Data Access Domain Model. If your base class is declared as abstract, then you should not specify a discriminator value for it.
Once the your l2s model is converted, the corresponding Telerik Data Access domain model should look like the snapshot below:
If you select any of the derived classes (for example Rottweiler) and navigate to Inheritance Mappings tab of the Mapping Details Editor, you will see information about the inheritance mapping. The inheritance strategy should be set to Flat, the Discriminator Column and Value should be specified.