Tamino API for .NET Version 8.2.2
 —  Tamino API for .NET  —

Performing Queries and Update Queries

The Tamino XQuery language can be used both to query Tamino XML documents and also to update them. For more information about the Tamino XQuery language, please refer to the Tamino Server documentation.

The Tamino API for .NET provides the Query method of the TaminoCommand to execute both kinds of transaction. The Query method always returns a TaminoQueryResponse object. Iterators can be requested from this TaminoQueryResponse object to process the returned query result set.

When querying data from the database, the returned query result is built according to the specified query. In the case of a query that updates XML data in Tamino, the returned query result set consists of a list of information that identifies the affected XML documents in Tamino. The application can use the serialization class TaminoUpdateItem to access this identifying information easily.

Examples

...
// querying data from Tamino
TaminoQuery query = new TaminoQuery ("input()/Property");
TaminoQueryResponse queryResponse = command.Query(query);
...
...
// updating data in Tamino
TaminoQuery updateQuery =
  new TaminoQuery("update replace for $p in input()/Property//Name where
                  $p=’Hugo Maier’ with <Name>Hugo Meier</Name>");
TaminoQueryResponse updateResponse = command.Query(updateQuery);
TaminoUpdateItem updateItem =
  (TaminoUpdateItem) updateResponse.GetSingleItem(typeof(TaminoUpdateItem));
Console.WriteLine("collection="+updateItem.collection+" doctype"+
                  updateItem.doctype+" id="+updateItem.id);
...

Using Tamino Cursors

If a query is expected to return a very large result set, it is generally better not to return the complete query result set all at once. Instead, the application can specify that the result set should be retrieved page by page. This is done by specifying a page size in the Query method of the TaminoCommand. If a page size greater than 0 is specified, the Tamino API for .NET will use the Tamino cursor.

A cursor can only be used for querying data from Tamino. It cannot be used in conjunction with an XQuery update expression.

A cursor can only be used within the scope of a local or global transaction (see dotnetapiref/SoftwareAG.Tamino.Api.TaminoConnectionMode.html).

Example

TaminoConnection connection = new TaminoConnection("http://myserver/tamino/mydb");
connection.Open(TaminoConnectionMode.LocalTransaction);
TaminoTransaction transaction = connection.BeginTransaction();
TaminoCommand command = connection.CreateCommand("mycollection");

// 10 items per page
TaminoQueryResponse qr = command.Query(new TaminoQuery("input()/Property"),10);
... 

Top of page

Closing a Query Result Set

You should call the Close method in the TaminoQueryResponse object when the query result set is no longer required, in order to release resources such as Tamino cursors. Resources are not implicitly released when the TaminoQueryResponse object falls out of scope or is reclaimed by the garbage collector.

Top of page