I use EF 4.0, and I would like to use the isolation level serializable, because in a transaction I would like to lock the register while reading.
Well, in SQL Server, I'm trying to change the isolation level with this command:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
And in C #, I use this code to try to lock case:
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.Serializable }))
{
Entities myContext = new Entities();
string colors = "select * from Colors where IDColor = 2";
Colors myColor = myContext.Colors.SqlQuery(colors).FirstOrDefault<Colors>();
myColor.Color = "Red";
myContext.SaveChanges();
scope.Complete();
}
If I execute a line string with my code, if I receive SaveChanges, but still not executed, if I query the table colors using SQL Server Management Studio, for example, I can get a record.
, scope.Clompete(), Management Studio, , , , #, Management Studio.
, : #? - ?
P.S.: , :
DBCC useroptions;
, serializable, Management Studio , readCommitted.
, , .