Data Access has been discontinued. Please refer to this page for more information.

How to: Set The Command Timeout

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

This article will give you details about how you can set the timeout for the execution of all Telerik Data Access operations:

On Global Level

On global level, the timeout for all Telerik Data Access operations can be set either through the Model Settings dialogue or in the app.config/web.config file of the project that holds the domain model.

Through The Model Settings Dialogue

The timeout setting can be applied with the help of the following steps:

  1. Open the domain model in Visual Designer.
  2. Right-click on the surface of the designer and select Show Model Settings... to open the Model Settings dialogue.
  3. Navigate to the Backend Configuration tab and select the Runtime page.
  4. Set the necessary value in the Command Timeout box

  5. Click OK to close Model Settings

  6. Save the domain model

In The Config File

Setting the timeout value in the app.config/web.config file can be achieved with the following process:

  1. Open the app.config/web.config file of the application.
  2. In the <configuration> section, create a new section called openAccessConfiguration:

        <section name="openAccessConfiguration"
                 type="Telerik.OpenAccess.Config.OpenAccessConfigSectionHandler, Telerik.OpenAccess"
                 requirePermission="false" />
  3. Set the timeout value in the new section as shown below:

          <backendConfiguration name="MyBackendConfiguration" backend="MsSql">
            <runtime commandTimeout="100"></runtime>
  4. Save the app.config/web.config file.

  5. The setting can be consumed like this:
BackendConfiguration fromCodeConfiguration = 
using (EntitiesModel dbContext = new EntitiesModel(fromCodeConfiguration))
        //a Telerik Data Access Operation
Dim fromCodeConfiguration As BackendConfiguration =  _
BackendConfiguration.MergeBackendConfigurationFromConfigFile(fromCodeConfiguration, _
Using dbContext As New EntitiesModel(fromCodeConfiguration)
        'a Telerik Data Access Operation
End Using

On Query Level

By design, Telerik Data Access will respect the timeout value on query level, if it is provided. In every other case, it will take into account the global one.

The following example demonstrates how to specify a timeout value on query level:

using Telerik.OpenAccess;
using (EntitiesModel dbContext = new EntitiesModel())
    List<Car> allCars = dbContext.Cars
                        .WithOption(new QueryOptions ()
                            CommandTimeout = 100 //in seconds
Imports Telerik.OpenAccess
Using dbContext As New EntitiesModel()
    Dim allCars As List(Of Car) = dbContext.Cars.
        WithOption(New QueryOptions() With
                       .CommandTimeout = 100 'in seconds
End Using

The WithOption() extension method resides in the Telerik.OpenAccess namespace

If a given Telerik Data Access operation exceeds the timeout value, a backend specific exception with the following text will be thrown:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.