private static void WithTransactionCore(INotebook notebook, Action action, bool rollback) { var didBeginTransaction = false; if (!notebook.IsTransactionActive()) { notebook.Execute("BEGIN"); didBeginTransaction = true; } try { action(); if (didBeginTransaction) { notebook.Execute(rollback ? "ROLLBACK" : "COMMIT"); } } catch { if (didBeginTransaction) { notebook.Execute("ROLLBACK"); } throw; } }
public static void WithTransaction(INotebook notebook, Action action) { bool didBeginTransaction = false; if (!notebook.IsTransactionActive()) { notebook.Execute("BEGIN"); didBeginTransaction = true; } try { action(); if (didBeginTransaction) { notebook.Execute("COMMIT"); } } catch { if (didBeginTransaction) { notebook.Execute("ROLLBACK"); } throw; } }