.net – 在SQL中什么是默认的最大事务超时
发布时间:2020-05-24 10:39:30 所属栏目:MsSql 来源:互联网
导读:如果machine.config上没有“system.transactions”元素,则maxTimeout的machine.config中的默认值是什么(参见示例)? system.transactions machineSettings maxTimeout=??:??:?? //system.transactions 我问这个是因为代码因以下异常而崩溃,似乎它与超时超
|
如果machine.config上没有“system.transactions”元素,则maxTimeout的machine.config中的默认值是什么(参见示例)? <system.transactions> <machineSettings maxTimeout="??:??:??" /> </system.transactions> 我问这个是因为代码因以下异常而崩溃,似乎它与超时超时的事务有关,它在SaveChanges方法期间崩溃,我收到的异常如下: The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements. 这是崩溃的代码片段: using (TransactionScope transaction = TransactionHelper.CreateTransactionScope())
{
using (EFContext efDBContext = new EFContext())
{
try
{
efDBContext.Connection.Open();
foreach (MyEntity currentEntity in myEntities)
{
//Insertion
}
transaction.Complete();
}
catch (Exception ex)
{
//Inspect current entity
//Get Total Time of the run
//Number of entities processed
}
finally
{
if (esfDBContext.Connection.State == ConnectionState.Open)
esfDBContext.Connection.Close();
}
}
}
这是我创建TransactionScope的方法: public static TransactionScope CreateTransactionScope(TransactionScopeOption option = TransactionScopeOption.Required,IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
{
var transactionOptions = new TransactionOptions()
{
Timeout = TimeSpan.MaxValue,IsolationLevel = isolationLevel
};
return new TransactionScope(option,transactionOptions);
}
解决方法默认= 10分钟.最大= Infinity(编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
