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

How to: Set Isolation Level

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.

Telerik Data Access allows you to provide a different value for the isolation level used by each instance of the context. To do so, you would set the IsolationLevel context option.

The value for the isolation level needs to be provided before the call to any of the operations which will be executed through the context.

using (EntitiesModel dbContext = new EntitiesModel())
{
    dbContext.ContextOptions.IsolationLevel = System.Data.IsolationLevel.ReadCommitted;
    //dbContext.ContextOptions.IsolationLevel = System.Data.IsolationLevel.ReadUncommitted;
    //dbContext.ContextOptions.IsolationLevel = System.Data.IsolationLevel.Snapshot;
    //...
    //Setting null for the isolation level on the context instance
    //will cause the transaction to use the default value of the given database server
    //dbContext.ContextOptions.IsolationLevel = null;
    //...
    //The CRUD operations to be executed through this instance of the context
    //...
}
Using dbContext As New EntitiesModel()
    dbContext.ContextOptions.IsolationLevel = System.Data.IsolationLevel.ReadCommitted
    'dbContext.ContextOptions.IsolationLevel = System.Data.IsolationLevel.ReadUncommitted
    'dbContext.ContextOptions.IsolationLevel = System.Data.IsolationLevel.Snapshot
    '...
    'Setting null for the isolation level on the context instance
    'will cause the transaction to use the default value of the given database server
    'dbContext.ContextOptions.IsolationLevel = Nothing
    '...
    'The CRUD operations to be executed through this instance of the context
    '...
End Using

Telerik Data Access will throw a System.ArgumentOutOfRangeException exception, if the values Chaos, RepeatableRead, Serializable, and Unspecified are provided.

Further Reference