Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

AutoManageTransactionAttribute

Trevor Pilley edited this page Mar 16, 2020 · 8 revisions

The AutoManageTransactionAttribute will ensure that an action is wrapped in a transaction if your controller inherits from MicroLiteController/MicroLiteReadOnlyController or implements IAsyncSession/IHaveReadOnlySession.


It will then ensure that the transaction is either rolled back or committed depending on whether the action results in an exception being thrown or not.

If you have registered an AutoManageTransactionAttribute in the global filters collection, there may be times when you may want to manually manage the transaction so it is easy to opt out per controller:

// Will affect all methods in the controller
[AutoManageTransaction(AutoManageTransaction = false)]
public class CustomerController : MicroLiteApiController { ... }

or per action:

// Will only affect individual methods
[AutoManageTransaction(AutoManageTransaction = false)]
public HttpResponseMessage Edit(int id, Model model) { ... }
Clone this wiki locally