How to: Set Isolation Level
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 (FluentModel dbContext = new FluentModel())
{
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 FluentModel()
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.