The Mapping Details Editor window is the component of the OpenAccess Visual Designer that enables you to view and edit mappings in the domain model. You can map types or associations to one or more database tables or functions.
The Mapping Details window is a Visual Studio component that is integrated with the Visual Designer. Double-click a .RLINQ file in the Solution Explorer to open the Visual Designer. This includes the Mapping Details window. The Mapping Details window is located at the bottom part of the Visual Designer, near to the ErrorList and Output panes.
If the Mapping Details window is not visible, it could be opened via the View -> Other Windows -> Entity Diagrams Details Editor menu command.
Mapping Details Editor
The Mapping Details window shows the mappings of the selected entity type in the currently active window.
The Mapping Details Editor offers four different views for configuring the Table mappings, Inheritance mappings and CUD (Create, Update, Delete) mappings.
Tables Mapping View
The Tables Mapping view is the default view. Here mappings between database tables and persistent classes could be edited. The snapshot below illustrates what will be visible in the Mapping Details Editor, if the Order class from the currently active domain model is selected. The "Mapped to" drop down shows the database table, to which the currently selected class is mapped. The "Mapped To" drop down contains all the available objects in the current domain model. That's why the drop down objects could be easily and quickly chosen.
The mapping details grid contains three columns:
- Column - represents an existing database column from the currently selected table ( e.g. Orders).
- ClassProperty - the class property, to which the present column is mapped. The CLR type of the property is also specified. For each column, you can click the ClassProperty field, and select the desired field to which the column will map.
The Inheritance Mapping view is the second view in the Mapping Details Editor. Here inheritance mappings between types in the current domain model can be edited.
The Inheritance Mapping view exposes the following inheritance options:
- Base Class - a drop down, which shows the base class for the currently selected type from the domain model.
- Discriminator Column - defines which row in the database belongs to which type in the persistent model. This is only necessary if the type is part of a class hierarchy.
- Discriminator Value - here the following options are available: Class Full Name, Class ID, Custom.
Telerik OpenAccess ORM supports three types of inheritance strategies:
- Flat - with flat mapping, fields from the subclasses are mapped to the superclass table. Flat mapping is the simplest and is usually the fastest option that's why it is the default.
- Vertical - with vertical mapping each class has its own table containing only its fields.
- Horizontal - horizontal inheritance can only be enabled for the topmost class in a hierarchy. Each immediate subclass is stored in its own table with a "copy" of the fields from the superclass. A horizontally mapped class, i.e. the superclass, does not have a table. Therefore, a horizontally mapped class cannot be directly persisted; only subclasses of the class can be stored in the database. For this reason, it is recommended (but not required) for horizontally mapped classes to be declared as abstract.
For more information about inheritance mapping, read Modeling Inheritance with Visual Designer
The CUD mapping view specifies the usage of a certain stored procedure in a class. This is useful when all create, update, delete operations should be accomplished through stored procedures. The CUD mapping view is shown on the snapshot below.
The view contains three tab pages, representing each one of the create, update, delete operations respectively. Each tab page contains the following options:
- Use stored procedures for - by default this field is unchecked. Which means that Telerik OpenAccess ORM will use plain SQL queries to perform the current operation (e.g. to update the corresponding database table). If a stored procedure should be used for updating the corresponding database table, then this field should be checked.
- Parameters grid - here information about the mapping between the stored procedure parameters and the class properties will be shown.
For more information, please refer to How to: Map CUD Operations to Stored Procedures.