Почему он терпит неудачу через 15 минут? Мне нужно установить еще одну настройку (тайм -аут)?
Код: Выделить всё
DbContextКод: Выделить всё
int timeout = Convert.ToInt32(new TimeSpan(0, 45, 0).TotalSeconds);
options.UseSqlServer(connectionstring,
x => x.CommandTimeout(timeout)) //timeout
< /code>
Code (выполнен в обработчике запроса Mediatr): < /p>
private static readonly string logLineStartedExecutingMethod = "Started executing method {MethodName}";
private static readonly string logLineFinishedExecutingMethod = "Finished executing method {MethodName} - {RecordCount}";
using var trans = new TransactionScope(TransactionScopeOption.RequiresNew, new TimeSpan(1, 0, 0), TransactionScopeAsyncFlowOption.Enabled);
_logger.LogInformation(logLineStartedExecutingMethod, "UspTestA");
var resultA = await _procedureRepository.UspTestAAsync(default, cancellationToken);
_logger.LogInformation(logLineFinishedExecutingMethod, "UspTestA", resultA?.ToString() ?? "0");
_logger.LogInformation(logLineStartedExecutingMethod, "UspTestB");
var resultB = await _procedureRepository.UspTestBAsync(default, cancellationToken);
_logger.LogInformation(logLineFinishedExecutingMethod, "UspTestB", resultB?.ToString() ?? "0");
_logger.LogInformation(logLineStartedExecutingMethod, "UspTestC");
var resultC = await _procedureRepository.UspTestCAsync(request.UserName ?? "Onbekend", default, cancellationToken);
_logger.LogInformation(logLineFinishedExecutingMethod, "UspTestC", resultC?.ToString() ?? "0");
_logger.LogInformation(logLineStartedExecutingMethod, "UspTestD");
// ERROR!!! Transaction timeout after approx. 15 minutes
var resultD = await _procedureRepository.UspTestDAsync(default, cancellationToken);
_logger.LogInformation(logLineFinishedExecutingMethod, "UspTestD", resultD?.ToString() ?? "0");
trans.Complete();
< /code>
Исключение: < /p>
system.transactions.transactionException: операция недопустима для состояния транзакции. /p>
system.timeOutexception: время-аут транзакции
--- Конец внутреннего стека исключений трассировки --- < /p>
в системе. Transactions />
at System.Transactions.Transaction.EllistPromotablesingPallphase (iProMotablesingPinglephasEnotification PRMOTABLEABLEPHASENOTICATIATIATION)
at microsoft.data.sqlclient.sqlinternalconnection.enlistnonnull (transaction tx)
at miclosoft.date. PrepareConnection (DBConnection WhoreingObject, DBConnectionInternal OBJ, транзакция) DBConnectionInternal & Connection)
at microsoft.data.providerbase.dbconnectionpool.waitforpendingopen ()
--- Конец трассировки стека из предыдущего местоположения ---
at microsoft. EntityFrameWorkCore.Storage.RelationalConnection.OpeninternalAsync (Boolean Errorsexprected, CancellationToken CancellationToken)
at microsoft.entityframeworkcore.storage.RelativeConnection.openinternalAsync (boolean errorsexpted, brelaltationtokkonetokkonkouktokkonkounktone. EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft. EntityFrameWorkCore.Query.Internal.FromSQLQUERYINGENUMERABLE1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Funcat microsoft.entityframeworkcore.entityframeworkqueryabletextensions.tolistasync [tsource] (iqueryable1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable< /code> 1 Источник, CancellationToken CancellationTokenekeoken)
at Data.StoredProcedures.dbcontextextensions.sqlqueryasync [t] (dbcontext db, string sql, объект [] Параметры, DecellationTokentoken) />
Подробнее здесь: https://stackoverflow.com/questions/784 ... ut-ef-core
Мобильная версия