Transaction Support in Kentico API?

Senior Software Engineer - Kentico Xperience MVP

Trevor Fayas asked on November 3, 2014 22:12

Just curious, does Kentico have any API support for transaction and roll back on things like Custom Tables? An example is if I have 1-to-many relationship in two Custom Tables (say A and B), and i need to do a 2 step update:

1: Delete the current items in B related to the item in A 2: Load in the new items that are related to item A into table B

If 1 is successful, but step 2 fails, can the step 1 be 'undone' via a transaction cancel / roll back?

Sorry for poor explanation.

Correct Answer

Brenden Kehren answered on November 4, 2014 04:42

Hey Trevor!

You should be able to use something like this:

using (CMSTransactionScope trans = new CMSTransactionScope())
{
    // do your work
    trans.Commit();
}
3 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.