Home

Vici CoolStorage - Documentation - Transactions

Transactions

Although CoolStorage is not session-based, transactions are fully supported.

To perform a series of actions in a single transaction, you should wrap the code in a using block, creating a CSTransaction object, like this:

using (CSTransaction transaction = new CSTransaction(IsolationLevel.ReadCommitted))
{
  Order order = Order.New();
  
  // fill order

  order.Save();

  transaction.Commit();
}

When in a transaction scope, all operations on CoolStorage objects will be part of the transaction.

The Dispose() method on the CSTransaction object will perform a rollback of the transaction if the Commit() method has not been called. You should always perform a Commit() on the transaction, otherwise the operations inside the transaction will not be executed.