Welcome Guest! To enable all features please Login or Register.



How to define a logical type
#1 Posted : Monday, July 30, 2012 6:04:04 PM(UTC)

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.
  1. 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.
  2. Give the type a unique name by setting the name attribute.
  3. Select or enter the type it extends from in the base attribute.
  4. 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.
  5. If the type is a string then specify the size attribute for the maximum length of the string if applicable.
  6. 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.
  7. 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.
  1. Specify a mapping to a database SQL type.
  2. Specify a mapping to an EDM type.
  3. Specify a mapping to a CLR type.
  4. Specify a mapping to a Data Property.
  5. Specify a mapping to a WPF control.
  6. Specify a mapping to a Web control.
  7. Specify a mapping to one of the declared enumeration.

Below is an example of a basic type declaration.
    <type name="PO number" base="string" size="10">
        <summary>Zero-padded 10-character PO number.</summary>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.