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));
private bool Exists(bool retryOnNotExists) { var retryCount = 0; var giveUp = DateTime.UtcNow + TimeSpan.FromMinutes(1); 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; } } } }
private bool Exists(bool retryOnNotExists) => Dependencies.ExecutionStrategyFactory.Create().Execute( DateTime.UtcNow + RetryTimeout, giveUp => { while (true) { try { using (new TransactionScope(TransactionScopeOption.Suppress)) { _connection.Open(errorsExpected: true); _connection.Close(); } return(true); } catch (SqlException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (DateTime.UtcNow > giveUp || !RetryOnExistsFailure(e)) { throw; } Thread.Sleep(RetryDelay); } } });
private bool Exists(bool retryOnNotExists) { var retryCount = 0; while (true) { try { _connection.Open(); _connection.Close(); return(true); } catch (SqlException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (!RetryOnExistsFailure(e, ref retryCount)) { throw; } } } }
public virtual bool Exists() { var exists = false; if (!_creator.Exists()) { return(exists); } var command = (SqlCommand)_connection.DbConnection.CreateCommand(); command.CommandText = @"SELECT 1 FROM [INFORMATION_SCHEMA].[TABLES] WHERE [TABLE_SCHEMA] = N'dbo' AND [TABLE_NAME] = '__MigrationHistory' AND [TABLE_TYPE] = 'BASE TABLE'"; _connection.Open(); try { exists = command.ExecuteScalar() != null; } finally { _connection.Close(); } return(exists); }
private bool Exists(bool retryOnNotExists) => Dependencies.ExecutionStrategyFactory.Create().Execute( giveUp => { while (true) { try { _connection.Open(); _connection.Close(); return(true); } catch (SqlException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (DateTime.UtcNow > giveUp || !RetryOnExistsFailure(e)) { throw; } Thread.Sleep(RetryDelay); } } }, DateTime.UtcNow + RetryTimeout);
public virtual bool Exists() { var exists = false; if (!_creator.Exists()) { return(exists); } var command = (SqlCommand)_connection.DbConnection.CreateCommand(); command.CommandText = "SELECT OBJECT_ID(N'dbo." + MigrationHistoryTableName + "');"; _connection.Open(); try { exists = command.ExecuteScalar() != DBNull.Value; } finally { _connection.Close(); } return(exists); }
protected virtual void Dispose(bool disposing) { if (disposing) { _connection.Close(); _connection.Dispose(); } }
private bool Exists(bool retryOnNotExists) => Dependencies.ExecutionStrategyFactory.Create().Execute( DateTime.UtcNow + RetryTimeout, giveUp => { while (true) { var opened = false; try { using var _ = new TransactionScope(TransactionScopeOption.Suppress); _connection.Open(errorsExpected: true); opened = true; _rawSqlCommandBuilder .Build("SELECT 1") .ExecuteNonQuery( new RelationalCommandParameterObject( _connection, null, null, Dependencies.CurrentContext.Context, Dependencies.CommandLogger)); return(true); } catch (SqlException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (DateTime.UtcNow > giveUp || !RetryOnExistsFailure(e)) { throw; } Thread.Sleep(RetryDelay); } finally { if (opened) { _connection.Close(); } } } });
public virtual void Close() => _realConnection.Close();
public virtual bool Close() => _realConnection.Close();