Typed View Editor, Field Mappings Tab

The Field Mappings tab is the tab which contains the information and editors for working with the mappings of the typed view definition on a target element in the Relational Model Data, e.g. a table, view or stored procedure resultset. The different parts are described below.

Typed View Mappings Tab

The Mappings tab

Typed View mapping and Field mappings

A typed view can be mapped to multiple targets, one target per database type. A database type represents a single Relational Model Data Storage container, you can have one of these per database type per project.

To map a typed view to a target, you first select the Relational Model Data Storage container using the combo box called Database type. Then, you click the Create mapping button to create a mapping definition for this typed view. The Remove mapping button removes the mapping definition.

Each mapping connects a model element (e.g. typed view) and a Relational Model Data element, e.g. a table, view or stored procedure resultset, which is called the target of the mapping. To select which table, view or stored procedure resultset a typed view maps to for the chosen database type, select the target from the combo box called Target.

To view the specifics of the target chosen, click the button next to the target combo box to look it up in the Catalog Explorer. If you want to create a new target for a typed view, you can click the New target button to open the dialog to specify the name for a new table.

As typed views are seen as containers for read-only data, there's no need for sequences and therefore the New sequence button is disabled.

Table Valued Function Resultset mappings

If the typed view is mapped onto the resultset of a table valued function call, the mapping can't be changed to a different target. This is because the typed view is set as the return element of the table valued function call and a table valued function call always has to have a return element: changing the target in the typed view mappings would make the table valued function call render without a return element.

Field mappings

Below the information for the typed view mapping are the mappings per typed view field shown. Per typed view field the .NET type of the typed view field is given and the target field it is mapped on. The target field is a field in the Target of the mapping. To select a target field, click the cell in the Target element name column to open the selector to pick the specific target field. The details about the selected target field are shown in the selector and for the selected field mapping also below the grid in the Target element details section, which is described below.

LLBLGen Pro contains auto-map functionality which already pre-selects target fields based onĀ  typed view field name and type specifics. This greatly reduces time spend on mapping a typed view to a target.

Sometimes the .NET type of the typed view field and the target field don't match. To match them, use a type converter and assign it to the particular field mapping by clicking the cell in the column 'TypeConverter to use'. Type converters are supported by the target frameworks LLBLGen Pro Runtime Framework, Entity Framework 2.1+ and NHibernate. Type converters for NHibernate have to implement IUserType as well as NHibernate only supports converts which implement that specific interface.

To synchronize the type specifics (.NET type, length, precision, scale) between the typed view field and the mapped target field, you can use the Sync selected... button. You have two choices:

  1. Sync Target Field with Model field. This sets the target field's database type, length, precision and scale to a type matching the .NET type, length and precision of the typed view field mapped onto it. This option is only enabled if the Target of the mapping is a table.
  2. Sync Model Field with Target Field. This sets the typed view field's .NET type, length, precision and scale to the .NET type, length, precision and scale of the mapped target field.

When a typed view field has to be mapped onto a new target field, you can either use the New field... button at the bottom or click the Auto-map unmapped fields to new target fields button, which automatically creates new fields in the Target of the mapping, using the type specifics and names of the typed view fields which aren't mapped to a target field yet. Several settings in Project Settings control the pre-selected type and the name construction of the newly created target fields. These buttons are only enabled if the Target of the mapping is a table.

When there are some unmapped target fields in the Target of the mapping and you want to reverse engineer them to typed view fields using the reverse engineering functionality of the designer, click the button Reverse-engineer unmapped target fields.

Target element details

The bottom section of the Field mappings tab contains the Target element details section, which displays the specific aspects of the target field of the selected row in the field mapped grid. To edit these specifics, click the Edit field... button, which will bring up the table field editor. You can only edit table fields.

If you want to create a new field in the Target of the mapping, click New field... which will bring up the same dialog as Edit field... except it now allows you to specify a new field's specifics.

If you want to map the currently selected typed view field to a new field, and don't want to spend time on specifying field specifics, you can click Auto-new field which creates a new target field in the Target of the mapping based on the selected typed view field and maps the typed view field on this newly created target field.

If the Target of the mapping isn't a table, you can't edit a target field nor create new ones.