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

Notification

Icon
Error

How to map a logical type to a database type
xomega
#1 Posted : Friday, July 27, 2012 7:02:32 PM(UTC)
xomega



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.
  1. 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"
  2. 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.
  3. Set the name attribute by selecting the SQL type from the list or by entering your own type.
  4. Set the db attribute to sqlsrv.
  5. 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).
  6. 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>
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.

Copyright © 2009-2022 Xomega.Net. All rights reserved.