Defines one or more properties for a column in a table. The optional value attribute, specifies the type of database that the mapping applies to or if it applies to all databases, if the database is not specified. So, you will only need one db-column extension unless you require different mappings for different database types.
The example below sets the length (precision) and scale of a System.Decimal field to (10,4) for all databases except Oracle, which is set to (12,4). OpenAccess ORM will use a NUMERIC column for the field by default so there is no need to specify the type of the column. Normally it is best to let OpenAccess ORM choose as many things as possible as this will result in a portable database schema:
|
Copy Code |
<field name="qty">
<extension key="db-column">
<extension key="db-length" value="10" />
<extension key="db-scale" value="4" />
</extension>
<extension key="db-column" value="oracle">
<extension key="db-length" value="12" />
<extension key="db-scale" value="4" />
</extension>
</field>
|
Valid child extensions:
Child Extension |
Description |
db-column-name |
Sets the name of the column. The name generator for the datastore of the table provides the default name. |
db-type |
Supported database datatypes |
db-sql-type |
Backend specific database types, i.e. MS SQL Server types, MySQL Server Types or Oracle types (Refer to Mapping a Simple Field for the various mappings).
The value of this extension should contain one of the "n-types" like nvarchar, if you want to have Unicode support with sql server. |
db-length |
Length (or precision) |
db-scale |
Scale (digits after the decimal point) |