众所周知,事务内部的数据库锁在事务结束时被释放。所以,在这段代码中..
public static TransactionScope CreateTransactionScope()
{
return new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted });
}
其实在这一...
using (DataContext dataContext = new DataContext())
using (TransactionScope rootScope = CreateTransactionScope())
{
using (TransactionScope nested = CreateTransactionScope())
{
Ticket ticket = dataContext.ExecuteQuery<Ticket>(
"SELECT * FROM Tickets WITH (UPDLOCK) WHERE id={0}", ticketId).First();
nested.Complete();
}
// Will the lock be still ON here? Because I don't need him to be!
}
何时释放行/页面锁(UPDLOCK) - 在处理嵌套事务或根事务之后?