Locks In C#
lockstatement is a syntactic sugar for atry/finallystatement withMonitor.EnterandMonitor.Exitlockcan only lock areference type- There are two locks
optimisticandpessimisticlocks
pessimistic lock
- You can lock Middle Tier (Transaction scope, EF or LINQ)
- Data Access Layer
- SQL Server
Middle Tier
TransactionOptions TransOpt = New TransactionOptions();
TransOpt.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
using(TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, TransOptions)) {}
ADO.NET (DAta Access Layer)
ADO.NET stands for ActiveX Data Object is a database access technology created by Microsoft as part of its .NET framework that can access any kind of data source.
SqlTransaction objtransaction = objConnection.BeginTransaction(System.Data.IsolationLevel.Serializable);
SQL
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;