If you have several fields in different objects that are logically of the same type, such as an order number or an event type, then you want to declare a logical type for that in the model and use it for all those fields. This will ensure that all those fields will have consistent size on the database side and consistent behavior on the user interface side.
To do this, you need to perform the following steps.
- Add a type element to the types grouping element in the most appropriate file. Typically it's recommended to declared the types in the file where they are used the most often.
- Give the type a unique name by setting the name attribute.
- Select or enter the type it extends from in the base attribute.
- Add type description inside the nested elements doc > summary. This will help developers use the proper types in the objects fields and service model parameters.
- If the type is a string then specify the size attribute for the maximum length of the string if applicable.
- If the type is generic and doesn't have to be referenced necessarily, then set the generic attribute to true on the config > usage nested elements of the type.
- To mark a type as deprecated you can set the replaced-by attribute on the usage element to indicate which type to use instead of this one.
Normally your type will inherit its configuration from its base type. However, you can override any configuration as follows.
- Specify a mapping to a database SQL type.
- Specify a mapping to an EDM type.
- Specify a mapping to a CLR type.
- Specify a mapping to a Data Property.
- Specify a mapping to a WPF control.
- Specify a mapping to a Web control.
- Specify a mapping to one of the declared enumeration.
Below is an example of a basic type declaration.
Code:1 2 3 4 5 6 7 | < types >
< type name = "PO number" base = "string" size = "10" >
< doc >
< summary >Zero-padded 10-character PO number.</ summary >
</ doc >
</ type >
</ types >
|