/// <inheritdoc /> public override void Rollback() { ThrowIfDisposed(); if (!InTransaction) { throw new InvalidOperationException("Already committed or rolled back."); } using (var cmd = new SQLiteServerCommand(_connection)) { cmd.CommandText = "ROLLBACK"; cmd.ExecuteNonQuery(); // remove the last one in the list _isolationLevels.Pop(); } }
/// <summary> /// Begin the transaction. /// </summary> internal void Begin(IsolationLevel isolationLevel) { ThrowIfDisposed(); AddAndValidateIsolationLevel(isolationLevel); try { using (var cmd = new SQLiteServerCommand(_connection)) { // depending on the connection level... cmd.CommandText = IsolationLevel == IsolationLevel.Serializable ? "BEGIN IMMEDIATE" : "BEGIN"; // execute that query cmd.ExecuteNonQuery(); } } catch { // we are not in doing that level anymore _isolationLevels.Pop(); throw; } }