private Task <bool> ExistsAsync(bool retryOnNotExists, CancellationToken cancellationToken) { return(ExecutionStrategyFactory.Create().ExecuteAsync( async(giveUp, ct) => { var retryCount = 0; while (true) { try { await _connection.OpenAsync(ct); _connection.Close(); return true; } catch (SqlException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return false; } if (DateTime.UtcNow > giveUp || !RetryOnExistsFailure(e, ref retryCount)) { throw; } await Task.Delay(100, ct); } } }, DateTime.UtcNow + TimeSpan.FromMinutes(1), cancellationToken)); }
private bool Exists(bool retryOnNotExists) => ExecutionStrategyFactory.Create().Execute( giveUp => { var retryCount = 0; while (true) { try { _connection.Open(); _connection.Close(); return(true); } catch (SqlException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (DateTime.UtcNow > giveUp || !RetryOnExistsFailure(e, ref retryCount)) { throw; } Thread.Sleep(100); } } }, DateTime.UtcNow + TimeSpan.FromMinutes(1));
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> protected override Task <bool> HasTablesAsync(CancellationToken cancellationToken = default(CancellationToken)) => ExecutionStrategyFactory.Create().ExecuteAsync( async(connection, ct) => (int)await CreateHasTablesCommand().ExecuteScalarAsync(connection, cancellationToken: ct) != 0, _connection, cancellationToken);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> protected override bool HasTables() => ExecutionStrategyFactory.Create().Execute( connection => (int)CreateHasTablesCommand().ExecuteScalar(connection) != 0, _connection);