/// <summary> /// Accepts the current transaction /// </summary> public override void CommitTransaction() { //Validating if exists currently a transaction if (this.Transaction == null) throw new InvalidOperationException("Can't start a transaction because a transaction already exists in this executer"); //Acceptig the transaction this.Transaction.Commit(); //Closing the connection this.Connection.Close(); //Cleaning the memory this.Transaction = null; }
/// <summary> /// Cancels the current transaction /// </summary> public override void RollBackTransaction() { //Validating if exists currently a transaction if (this.Transaction == null) throw new InvalidOperationException("A transaction has not being initialized and therefore can't be rolled back"); //Canceling the transaction this.Transaction.Rollback(); //Closing the connection this.Connection.Close(); //Cleaning the memory this.Transaction = null; }
/// <summary> /// Starts a transaction for all the querys executed throught the Executer /// </summary> public override void BeginTransaction() { //Validating if dont exists currently a transaction if (this.Transaction != null) throw new InvalidOperationException("Can't start a transaction because a transaction already exists in this executer"); //Getting the default connection try { //Starting the transaction OpenConnection(); Transaction = Connection.BeginTransaction(); } catch { //Cleaning the memory Transaction = null; //Throwing the exception throw; } }