Specifies the default encoding of string values used in the schema.
<StringEncoding
encoding=("Ansi"|"Unicode")
[codepage="collation-type"]
/>
-
encoding
-
A value of Ansi specifies that string values should be converted to non-Unicode using the specified codepage.
A value of Unicode specifies that string values should be handled with Unicode encoding. The default is Unicode.
-
codepage
-
A Microsoft SQL Server collation name used for non-Unicode strings. If omitted, the database default collation
is used.
Remarks
String values can be stored in the underlying relational database system with different encodings. The
<StringEncoding> element
can be used to specify the default string encoding
model for the schema. The specified encoding type determines how strings are handled in the following
areas:
-
Mapping persistent fields to database fields. The string properties mapped with
<PersistentField> element
use the specified
encoding if no encoding
database type modifier
is used.
-
Database types of the created stored functions.
If no encoding
database type modifier
is used for the parameters, the specified encoding is used.
-
Transmitting string literals and client-side evaluated string expressions to the underlying relational database system.
These string values are transmitted to the database as SQL parameters. The usage and the type of these
parameters depend on the specified encoding and codepage, following these
rules:
-
If the encoding is Unicode, Unicode (nvarchar) parameters are
created.
-
If the encoding is ANSI and no codepage is specified,
non-Unicode (varchar) parameters are created.
-
If the encoding is ANSI but a specific codepage is
specified,
Genome
uses Unicode (nvarchar) parameters, but each parameter
usage is surrounded by a T-SQL collation and cast operator.
When the database schema contains both Unicode and non-Unicode string fields, the default string encoding should be set to Unicode.
In this case, each occurrence of a non-Unicode string expression can be converted to ANSI by using the String.ToAnsi() method.
Please note that comparing Unicode string expressions to non-Unicode persistent fields in an OQL query can cause serious performance
problems for large databases.
For Oracle databases (where the GUID data type is represented as a string database field), the GUID mapping
defaults can be changed through the
<GuidStringEncoding> element
element.
Requirements
Type: TechTalk.Genome.Schema.Builder.Xml.StringEncodingXmlData
Assembly: TechTalk.Genome.dll
Version: 4.2.4
Editions: Professional, Evaluation, Express
Database Platforms: Microsoft SQL Server 2000, Microsoft SQL Server 2005, Oracle 9i Release 2, Oracle 10g Release 2
See Also
String.ToAnsi() Method | Database Type Modifiers | XmlMapping.Elements.PersistentField