C# nsaction和对其调用Dispose(),以及关闭和处理数据库连接。”他们立即给出了一个示例,其中catch中有一个显式回滚。我做了一些进一步的挖掘,发现他们的回滚是多余的,因为Dispose()覆盖了回滚它由using语句触发。 //... code
nsaction和对其调用Dispose(),以及关闭和处理数据库连接。”他们立即给出了一个示例,其中catch中有一个显式回滚。我做了一些进一步的挖掘,发现他们的回滚是多余的,因为Dispose()覆盖了回滚它由using语句触发。C# nsaction和对其调用Dispose(),以及关闭和处理数据库连接。”他们立即给出了一个示例,其中catch中有一个显式回滚。我做了一些进一步的挖掘,发现他们的回滚是多余的,因为Dispose()覆盖了回滚它由using语句触发。 //... code,c#,sql,sql-server,entity-framework,C#,Sql,Sql Server,Entity Framework,nsaction和对其调用Dispose(),以及关闭和处理数据库连接。”他们立即给出了一个示例,其中catch中有一个显式回滚。我做了一些进一步的挖掘,发现他们的回滚是多余的,因为Dispose()覆盖了回滚它由using语句触发。 //... code that begins the request and loads the account into context. // Some pages may run code that looks something like this. us
//... code that begins the request and loads the account into context.
// Some pages may run code that looks something like this.
using(var tran = existingCtx.Database.BeginTransaction(IsolationLevel.RepeatableRead))
{
// Lock customer.
var act = ctx.Accounts.Find(purchaseFor.ID);
if (act == null)
throw new RecordNotFoundException("Unable to find specified customer.");
DoStuffRelyingOnLock();
Commit();
}