Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Optimistic Concurrency with Stored Procedures
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Stored Procedures Support > Optimistic Concurrency with Stored Procedures

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

Telerik OpenAccess ORM supports the ‘version’ and ‘all’ optimistic concurrency modes while using stored procedures for write operations. The ‘version’ mode is the same as while using dynamic SQL.

The ‘all’ concurrency mode is a specialized version of the ‘changed’ concurrency mode. As the stored procedure interface is static in nature i.e. the number of parameters is fixed, Telerik OpenAccess ORM needs to pass in all the column values and not only the ones that have changed.

Passing old and new column values

In order to perform the UPDATE operation using optimistic concurrency, Telerik OpenAccess ORM needs to pass in the old value of certain columns (depending on the concurrency mode) along with the new/changed values. For the ‘version’ concurrency mode the old and new value of the version field is passed and in case of the ‘all’ mode, the old and new values of all fields except the primary key, are passed.

Telerik OpenAccess ORM defines the “cc” attribute to specify that a parameter carries the old value of a field/column. This attribute can be specified at the parameter mapping.

Rows affected

In order to perform optimistic concurrency checks, the number of rows affected by executing the stored procedure needs to be obtained. This value, depending on the backend, is either returned as a property on the data reader  or as an OUT parameter of the procedure. To standardize the stored procedure usage, Telerik OpenAccess ORM requires the procedure to return the ‘rows affected’ value as an OUT parameter. For a user mapped procedure the ‘rowsAffectedParam’ attribute can be used to specify which parameter carries this value.


The following example shows the mapping for the UPDATE procedure for the ‘Category’ class. The ‘cc’ attribute for the ‘CategoryNameOld’ parameter specifies that this parameter holds the old value of the field. The ‘rowsAffectedParam’ attribute specifies the name of the parameter that carries the value of the number of rows affected. If the ‘rowsAffectedParam’ attribute is specified a corresponding parameter entry with the same name needs to be present.

Procedure mapping Copy Code
<class name="Category">
<update name="UpdateCategoryName" rowsAffectedParam ="rowsAffected">
<parameter name="CategoryName" field="categoryName" />
<parameter name="CategoryNameOld" field="categoryName" cc="true"/>
<parameter name="CategoryID" field="categoryID" />
<parameter name=" rowsAffected ">


If only the name of the stored procedure is specified in the mapping and no parameter mapping exists, Telerik OpenAccess ORM will generate the required parameters including the rows affected parameter, but if parameter mappings are specified then the rows affected parameter and other required parameters need to present in the mapping.