page header

Working with types and default values using Type Shortcuts

The LLBLGen Pro designer works with Type Shortcuts which define a shortcut (which is a name, e.g. 'string') to a .NET type and, optionally, a default length, precision and / or scale. Type Shortcuts are an easy way to specify the types for fields in entities, typed views and the like as they have short, easy to remember names. By default the designer comes with a set of System Type Shortcuts, which define all .NET types supported by all supported database drivers and which map to normal .NET types. System Type Shortcuts are read-only and can't be modified.

Additionally you can define Custom Type Shortcuts which allow you to define new shortcuts for known .NET types and optionally a default length, precision and / or scale. Custom Type Shortcuts are modifyable. This allows you to define e.g. a new string type, for example 'EmailAddress' which is a shortcut to System.String and has a different default length as the normal string shortcut, e.g. 150.

When a Type Shortcut is used as the type of a field in e.g. an entity definition, the default length, precision and scale set for the type shortcut is used to set the max. length, precision and scale of the field. This makes it easy to quickly define fields with a specific characteristic, e.g. a string field with length 100 or a decimal field with scale 3.

Editing Type Shortcuts is done in the Project Settings.

Default constraints for types / table fields.

When working Model First, it's sometimes required to be able to specify default values / constraints for a table field. Custom Type Shortcuts make this possible: they allow you to specify default values for a Type Shortcut - Database type (selected from the ones available in the project) combination. This allows you to control what default value is assigned to a target field solely through a type shortcut, so no extra actions have to be taken: defining the type on the entity field is enough.

Editing default values

To edit a default value for a type shortcut, you open the project settings and click on the type shortcut tree node. In the custom type shortcuts tab, for a single selected type shortcut in the custom typeshortcuts grid it allows you to specify per database (driver id) in the project a string, which is the default value for that type shortcut. When no value is specified, an existing default value for that database type is removed for that selected type shortcut.

In most cases a default value is not to be used for Identifying / Primary key fields. If you want the default value to be set on Identifying fields which have the type shortcut set as their type, check the Also on PK fields checkbox. If left unchecked, the default value is ignored for PK / Identifying fields and considered empty, so a default value on a PK field is then set to the empty string.

Applying the default value to table fields

When the project is validated and the relational model data is adjusted, the target field gets its default value updated if the source field has a Type Shortcut which has a default value defined for that database / driver id. A default value on a table field is always overwritten, if the type shortcut is a custom type shortcut. If the Also on PK fields is not set for a default value, and the field is a PK field, the default value is overwritten with the empty string.


LLBLGen Pro Designer v4.2 documentation. ©2002-2015 Solutions Design