page header

Type Conversion Definition Editor

To overcome .NET type mismatches between the model element and the mapped target element, the LLBLGen Pro designer supports Type converters. Type converters are classes which can convert from one .NET type to another and vice versa. Type Converters are supported on the LLBLGen Pro runtime framework and NHibernate (for NHibernate, the TypeConverter type has to implement the NHibernate specific interface IUserType).

To set a type converter for a field, you do so on a Field Mappings Tab of the containing element's editor. This can be a time consuming process if your project has a lot of fields which require a type converter. To overcome this, the designer supports Type Conversion Definitions. These type conversion definitions define for a given .NET type pair and optionally a set of filters, a type converter. If the designer recognizes this .NET type pair and optionally filters match too, and additionally the Project Properties setting AutoAssignTypeConverterToFieldMapping is set to true, the type converter of the defined Type Conversion Definition is assigned to the model field automatically. This happens when you refresh the relational model data or when you map an entity onto a target element.

Type Conversion Definitions are stored per database, as different target databases can require different type converters or different filters (as the filters are target database specific). To edit type conversions for a given project, right-click the project node in Project Explorer and select Edit Type Conversion Definitions... or select Project -> Edit Type Conversion Definitions... from the main menu.

The Type Conversion Definition editor edits the type conversions per database. Only databases which currently have a Relational Model Data storage in the project are selectable.

In the Defined type conversion definitions list, the currently defined type conversion definitions are shown with the filters, types and type converters they are based on. To remove a type conversion definition, select it in the grid and click Remove selected. To add a new type conversion definition, click the Add new... button. This will open a dialog which is described more in detail below.

Adding a new Type Conversion Definition

When you click the Add new... button, a dialog is opened which allows you to define the base elements for a type conversion definition. You start by selecting the Relational Model data .NET type. This is the .NET type related to the database type of the table/view field. This type is called the from type. Based on this .NET type, the list of Type converters to select from in the Converter to use combo box is filtered. After you've selected a type converter in the Converter to use combo box, the Model .NET type is known, as that's the core type of the type converter. Click the OK button to create the Type Conversion Definition, which will be a conversion definition between the Relational Model Data .NET type and the Model .NET type using the Converter to use type converter.

Additional Filters

Per type conversion definition you can specify extra filters. This can be useful when more than one database type results in the same .NET type, or you want to filter on length for example. To enable a filter, check the checkbox in front of a filter element at the bottom in the Additional filters on database field properties area. If a filter is enabled, it has to match exactly with the target field's specific property, e.g. length or precision to get the type converter of the particular type conversion definition assigned to the field mapping.


LLBLGen Pro Designer v3.0 documentation. ©2002-2010 Solutions Design