public VirtuosoCommand(string cmdText, VirtuosoConnection connection, VirtuosoTransaction transaction) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoCommand.ctor()"); this.commandText = cmdText; this.connection = connection; this.transaction = transaction; this.parameters = new VirtuosoParameterCollection(this); }
internal void OnConnectionClose() { if (isFetching) { CloseDataReader(); } DisposeStatement(); transaction = null; }
public void RollbackNoWork(TestCaseResult result) { CheckTransactionCapable(result); CheckTable(result); VirtuosoTransaction t = connection.BeginTransaction(); result.FailIfNotSame(connection, t.Connection); t.Rollback(); CheckTable(result); }
public void Commit(TestCaseResult result) { CheckTransactionCapable(result); CheckTable(result); VirtuosoTransaction t = connection.BeginTransaction(); InsertRow(3); InsertRow(4); CheckTable(result); t.Commit(); CheckTable(result); }
public void Rollback(TestCaseResult result) { CheckTransactionCapable(result); CheckTable(result); VirtuosoTransaction t = connection.BeginTransaction(); InsertRow(3); InsertRow(4); CheckTable(result); t.Rollback(); DeleteRow(3); DeleteRow(4); CheckTable(result); }
protected override void Dispose(bool disposing) { try { if (disposing) { DisposeStatement(); } base.Dispose(disposing); if (connection != null && connection.innerConnection != null) { connection.innerConnection.RemoveCommand(this); } connection = null; transaction = null; } catch (Exception e) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoCommand.Dispose caught exception: " + e.Message); } }
internal VirtuosoTransaction CheckTransaction (VirtuosoTransaction transaction) { if (transactionStrongRef != null) { VirtuosoTransaction currentTransaction = (VirtuosoTransaction) transactionStrongRef; if (currentTransaction != transaction) { if (currentTransaction == null) EndTransaction (false); if (transaction == null) throw new InvalidOperationException ("The transaction is not set."); else throw new InvalidOperationException ("The transaction is not associated with the connection."); } } else if (transaction != null) { if (transaction.Connection != null) throw new InvalidOperationException ("The transaction is not associated with the connection."); transaction = null; } return transaction; }
internal void EndTransaction (bool commit) { if (state == System.Data.ConnectionState.Closed) throw new InvalidOperationException ("The connection is closed."); if (autocommit) throw new InvalidOperationException ("No transaction is active."); innerConnection.EndTransaction (commit); transactionStrongRef = null; autocommit = true; }
public VirtuosoTransaction BeginTransaction (IsolationLevel level) #endif { Debug.WriteLineIf (CLI.FnTrace.Enabled, "VirtuosoConnection.BeginTransaction (level = " + level + ")"); if (state == ConnectionState.Closed) throw new InvalidOperationException ("The connection is closed"); CLI.IsolationLevel isolation; switch (level) { case IsolationLevel.ReadUncommitted: isolation = CLI.IsolationLevel.SQL_TXN_READ_UNCOMMITTED; break; case IsolationLevel.ReadCommitted: isolation = CLI.IsolationLevel.SQL_TXN_READ_COMMITED; break; case IsolationLevel.RepeatableRead: isolation = CLI.IsolationLevel.SQL_TXN_REPEATABLE_READ; break; case IsolationLevel.Serializable: isolation = CLI.IsolationLevel.SQL_TXN_SERIALIZABLE; break; case IsolationLevel.Unspecified: isolation = CLI.IsolationLevel.SQL_TXN_READ_COMMITED; break; default: throw new Exception ("Unknown or unsupported isolation level"); } VirtuosoTransaction transaction = null; if (!autocommit && transactionStrongRef != null) { transaction = (VirtuosoTransaction) transactionStrongRef; if (transaction != null) throw new InvalidOperationException ("Another transaction is running."); EndTransaction (false); } innerConnection.BeginTransaction (isolation); autocommit = false; transaction = new VirtuosoTransaction (this, level); transactionStrongRef = transaction; return transaction; }
public VirtuosoCommand (string cmdText, VirtuosoConnection connection, VirtuosoTransaction transaction) { Debug.WriteLineIf (CLI.FnTrace.Enabled, "VirtuosoCommand.ctor()"); this.commandText = cmdText; this.connection = connection; this.transaction = transaction; this.parameters = new VirtuosoParameterCollection (this); }
internal void OnConnectionClose () { if (isFetching) CloseDataReader (); DisposeStatement (); transaction = null; }
protected override void Dispose (bool disposing) { try { if (disposing) { DisposeStatement (); } base.Dispose (disposing); if (connection != null && connection.innerConnection != null) connection.innerConnection.RemoveCommand (this); connection = null; transaction = null; } catch (Exception e) { Debug.WriteLineIf(CLI.FnTrace.Enabled, "VirtuosoCommand.Dispose caught exception: " + e.Message); } }