public void ExecuteTransaction( System.Data.IsolationLevel isolationLevel, Action<Danny> transactionPayload, int maximumAttempts = 30) { if (_transaction != null) { throw new InvalidOperationException("Cannot create non-nested transactions per connection"); } var attempt = 0; var exceptions = new List<Exception>(); var random = new Random(); while (true) { attempt++; try { var connection = _connectionFactory(); connection.DisallowDispose(); var transaction = connection.Connection.BeginTransaction(isolationLevel); var danny = new Danny(transaction, () => connection, null); transactionPayload(danny); break; } catch (Exception ex) { exceptions.Add(ex); if (attempt == maximumAttempts) { throw new AggregateException( $"Maximum number of attempts reached ({maximumAttempts}) when executing transaction payload", exceptions); } Thread.Sleep(random.Next(200, 500)); } } }
public Session(string connectionString) { _danny = new Danny(connectionString); }
private Session(Danny danny) { _danny = danny; }
public Query(Danny danny, string query) { _danny = danny; _query = query; }