TechTalk Genome v4.2

<TransientField> Element

Defines a transient field that is not persisted in the database.

<Member name=" property ">
<TransientField [ OqlInitializer=" oql-expression " ] />
<Member name="property">
<OqlInitializer source=" oql-expression "
[ stored-function-directive ]
The name of the property mapped as a transient field.
An OQL expression returning a value that is compatible with the return type of the property. When the object is loaded from the database, the transient field is initialised with the value of the oql-expression.
The <StoredFunction> element specifies that a stored function has to be generated out of oql-expression in the underlying relational database system.


The <TransientField> element defines that the property is a field of the object, but it is not directly bound to a database field. Similarly to the <PersistentField> , the property accesses the object state in the Context associated with the object.

If no OqlInitializer is specified, the property can be of any arbitrary type as it does not have to be bound to the database. Of course, the property cannot be used in OQL expressions for the same reason. A transient field without an initialiser behaves like a C# field on a POCO; the value can be freely get and set, and getting an uninitialised transient field returns a null reference for reference types and the default value for value types.

If there is a specified OqlInitializer, the property must have a scalar return type. In this case, the transient field is populated with the value of the oql initializer expression when the object is loaded from the database. If the object is already in memory, the transient field can be freely get and set, and the initializer will be not executed again. If the transient field is not loaded yet (eg. new object or partially loaded object) an appropriate query is executed to populate the value of the transient field (lazy loading). By specifying the initializer, the property can be used in OQL expressions, just as if it were mapped with the <Oql> element .


  public abstract class Customer : Persistent {
    public abstract decimal? OrderVolume { get; }

  <Type name="Customer">

      <Member name="OrderVolume">
          <TransientField OqlInitializer="Sql.Sum([Value]Orders)" />



Type: TechTalk.Genome.Mapping.TransientFieldXmlData

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

XmlMapping.Elements.PersistentField | <Oql> Element