TechTalk Genome v4.2

<RawSql> Element

Defines the translation of a member to the SQL language variant of the underlying relational database system by a raw SQL expression.

<Member name=" member "
RawSql=" raw-sql-expression "


<Member name=" member ">
<RawSql source=" oql-expression " accessedTypes="(none|all|accessed-type-list)" />
A member name specifying a property or a method of scalar return type.
A raw SQL expression containing OQL snippet expressions.
A comma-delimited list of persistent types on which the raw SQL expression depends. If not specified, the default value is all, and a warning is generated during the schema compile.


The <RawSql> element can be used to map member by using special platform-specific features of the underlying relational database system. The raw-sql-expression contains an SQL expression written in the SQL language variant of the underlying relational database system.

The raw-sql-expression can contain OQL snippet expressions in specific blocks surrounded by {! and !} symbols. With OQL snippet expressions, the same rules have to be followed as with the oql-expression parameter of <Oql> element . When the member is translated, the OQL snippets in the raw-sql-expression are replaced by the translated values of the OQL expressions.

The accessed-type-list informs the Genome engine of the types whose modifications have to be updated to the database before the SQL expression can be processed. The all keyword means that the actual accessed types cannot be defined, so every pending modification should be updated. The none keyword specifies that the expression does not depend on any type.


This example shows how to map the SQL-specific LIKE operator to a static method of a helper class. This is an example only - the LIKE operator is already mapped in Genome as String.IsLike(String pattern) method.

public class SqlHelper {
    static public bool IsLike(string s, string pattern) {
<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">

    <Type name="SqlHelper">
        <Member name="IsLike" signature="string, string">
            <RawSql source="{!s!} LIKE {!pattern!}" accessedTypes="none"/>


Type: TechTalk.Genome.Mapping.RawSqlXmlData

Assembly: TechTalk.Genome.dll

Version: 4.2.11

Editions: Professional, Evaluation, Express

Database Platforms: Microsoft SQL Server 2000, Microsoft SQL Server 2005, Oracle 9i Release 2, Oracle 10g Release 2

See Also

Member Mappings | <Oql> Element