/// <summary> /// Executes the statment with transaction. /// </summary> /// <param name="pConnection">The p connection.</param> /// <param name="handler">The handler.</param> /// <param name="completed">The completed.</param> /// <param name="error">The error.</param> public void ExecuteStatmentWithTransaction(DbConnection pConnection, StatmentHandler handler, StatmentCompletedHandler completed, StatmentErrorHandler error) { try { this.ExecuteStatmentWithTransaction(pConnection, handler); completed(); } catch (Exception e) { error(e); } }
/// <summary> /// Execute a statment with transaction /// </summary> /// <param name="connection">Connection</param> /// <param name="handler">Handler</param> public void ExecuteStatmentWithTransaction(DbConnection pConnection, StatmentHandler handler) { if (pConnection == null) { pConnection = CreateConnection(null, this.ChooseCurrentConnectionString()); } if (pConnection == null) { throw new RecordConnectionNullException("You enabled context and init it for this execution"); } if (handler == null) { throw new RecordHandlerNullException(); } try { pConnection.Open(); DbTransaction transaction = pConnection.BeginTransaction(); try { handler(transaction); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); throw new TargetInvocationException(e); } finally { pConnection.Close(); } } catch (Exception e) { throw new TargetInvocationException(e); } }
/// <summary> /// Executes the statment with transaction. /// </summary> /// <param name="pConnection">The p connection.</param> /// <param name="handler">The handler.</param> /// <param name="completed">The completed.</param> public void ExecuteStatmentWithTransaction(DbConnection pConnection, StatmentHandler handler, StatmentCompletedHandler completed) { this.ExecuteStatmentWithTransaction(pConnection, handler); completed(); }
/// <summary> /// Execute a statment with transaction /// </summary> /// <param name="handler">Handler</param> public void ExecuteStatmentWithTransaction(StatmentHandler handler) { ExecuteStatmentWithTransaction(null, handler); }