Normally if you extend your logical type from another base type in the model, it will automatically inherit the mapping to the SQL type from its parent. For string types you can just override the maximum length by setting the
size attribute on your logical type. If your type does not extend any other logical type, or you just want to override the mapping to the SQL type, then the following steps outline this process.
- Make sure that the module element that contains your logical type declares a prefix for the "http://www.xomega.net/sql" namespace, e.g. xmlns:sql="http://www.xomega.net/sql"
- Add a sql:type element inside of the config element of your logical type definition. In the absence of such element your logical type will just inherit the SQL type from its base type if one exists.
- Set the name attribute by selecting the SQL type from the list or by entering your own type.
- Set the db attribute to sqlsrv.
- To specify the character length of a type you need to set the size attribute on the parent logical type. For all other type facets, you can add them as part of the SQL type name, e.g. nvarchar(max) or decimal(5,2).
- To validate your setup find a field that uses your logical type and then generate the database script and check the type of the corresponding columns.
Here is a sample configuration that illustrates these steps.
Code:
<module xmlns="http://www.xomega.net/omodel"
xmlns:sql="http://www.xomega.net/sql">
<types>
<type name="sample" base="string" size="20">
<config>
<sql:type name="nvarchar" db="sqlsrv"/>
</config>
</type>
</types>
</module>