Table per Concrete Type

The Table Per Concrete (TPC) Type inheritance (in Telerik Data Access terms, Horizontal inheritance) is an inheritance that is used when the database contains two or more tables with sets of identical columns.

For example, suppose that in the database we have the TPC_Horse and TPC_Dog tables. Both these tables contain the following identical columns: BirthDate and Genus.

Within the Database First approach, used for the purpose of this example, first, we move the TPC_Horse and TPC_Dog tables onto the design surface to create classes with the same respective names:

Images_TPC_Start_TDA

Next, we move identical properties (BirthDate and Genus) from one of the classes onto the diagram surface. Note that we cannot move the ID property, because in Telerik Data Access the derived classes must have primary keys in Horizontal hierarchy.

This displays the following dialog box:

Images_ChooseActionTPC

In the dialog box above, we select New base class and enter a name for the abstract class, for example, TPCBaseEntity, and click OK.

Open the Inheritance Editor dialog box for the created inheritance and select Table Per Concrete Type in the Type combo-box:

Images_TPC-Inheritance-Editor

At this stage, a TPC inheritance is created between the class, from which we moved the identical properties and the TPCBaseEntity class. The model looks as follows:

Images_TPC_Model_2_TDA

In the Properties window of the TPCBaseEntity class, we set Abstract to True.

Now we shall move the identical properties from the other class onto the diagram surface. The Model Refactoring dialog box is displayed again with the following selection:

Images_ChooseActionTPC2

If the automatic selection of the parameters is different, it will be necessary to select the Existing base class and select the TPCBaseEntity class from the corresponding drop-down list.

When we click OK in the dialog box, we get the final version of the model with correctly set inheritances:

Images_TPC_Model_Final_TDA

 

ExpandedToggleIcon        See Also


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.