TechTalk Genome v4.2

<Oql> Element

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

<Member name=" member "
Oql=" oql-expression "


<Member name=" member ">
<Oql source=" oql-expression " >
A member name specifying a property or a method.
An OQL expression returning a value that is compatible with the return type of the member.
The <StoredFunction> element specifies that a stored function has to be generated out of oql-expression in the underlying relational database system.


The <Oql> element defines the translation of the member to the SQL language variant of the underlying relational database system. The translation is specified by the oql-expression. The type of oql-expression has to be compatible with the return type of member.

The parameters of the member can be referred in oql-expression by their names. Parameters used in oql-expression hide instance members or unqualified member references with the same name. In the case of instance members, the object instance on which member is called can be referred by the this keyword. Using the this keyword is optional. Unqualified member references are implicitly qualified by the this keyword.

If oql-expression returns a Set, the return value of member can be marked with ElementTypeAttribute, thereby specifying the element type of the returned Set. Operations on candidate elements of sets returned by members of the specified element type can be performed without casting the candidate element. If the ElementTypeAttribute on member is omitted, an element is assumed to be of the type object.

When the <Oql> element is specified on an abstract method or property of the type, the proxy class generated by Genome implements the member by evaluating oql-expression. In this case, abstract properties may have a getter only.

By specifying stored-function-directive, Genome generates a stored function from member to support execution of recursive OQL expressions on the underlying relational database system.


In this example, the CalcSum method of the Order class is mapped as an OQL expression that calculates the sum price of the order items, taking into account a specified discount and shipping costs.

public abstract class Order : Persistent {
    public abstract double GetTotalPrice();
    public abstract double CalcSum(double discount, int shippingCost);
<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
    <Type name="Order">
        <Member name="GetTotalPrice"
            Oql="Sql.Sum([UnitPrice * Quantity]extentof(OrderDetails)[od: od.Order == this])" />
        <Member name="CalcSum" signature="double, int" 
            Oql="(1 - discount) * GetTotalPrice() + shippingCost" />


Type: TechTalk.Genome.Mapping.OqlXmlData

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 | <RawSql> Element | <StoredFunction> Element | OQL Syntax Guide