/// <summary> /// Executes the action specified by the given callback object within a transaction. /// </summary> /// <param name="action">The callback object that specifies the transactional action.</param> /// <returns> /// A result object returned by the callback, or <code>null</code> if one /// </returns> /// <remarks>Allows for returning a result object created within the transaction, that is, /// a domain object or a collection of domain objects. An exception thrown by the callback /// is treated as a fatal exception that enforces a rollback. Such an exception gets /// propagated to the caller of the template. /// </remarks> /// <exception cref="Spring.Transaction.TransactionException"> /// In case of initialization or system errors. /// </exception> public object Execute(ITransactionCallback action) { ITransactionStatus status = _platformTransactionManager.GetTransaction(this); object result; try { result = action.DoInTransaction(status); } catch (Exception ex) { rollbackOnException(status, ex); throw; } _platformTransactionManager.Commit(status); return(result); }
/// <summary> /// Executes the action specified by the given callback object within a transaction. /// </summary> /// <param name="action">The callback object that specifies the transactional action.</param> /// <returns> /// A result object returned by the callback, or <code>null</code> if one /// </returns> /// <remarks>Allows for returning a result object created within the transaction, that is, /// a domain object or a collection of domain objects. An exception thrown by the callback /// is treated as a fatal exception that enforces a rollback. Such an exception gets /// propagated to the caller of the template. /// </remarks> /// <exception cref="Spring.Transaction.TransactionException"> /// In case of initialization or system errors. /// </exception> public object Execute(ITransactionCallback action) { ITransactionStatus status = _platformTransactionManager.GetTransaction( this ); object result; try { result = action.DoInTransaction(status); } catch ( Exception ex ) { rollbackOnException( status, ex ); throw; } _platformTransactionManager.Commit( status ); return result; }