I'm currently working on a stored procedure that will perform a couple of inserts into a database table and I want to test and see if it can return the total rows affected in a way I'd like it to. And I'm calling this stored procedure from my C# .NET code inside a transactionscope.
My question however, is how I can trigger a rollback after the stored procedure is executed and the rows affected is displayed on the console?
I'm not allowed to share my code, but I can give a pseudo code of it as it's quite simple:
using(TransactionScope scope){
//Run the procedure and save the return value in a variable
int rowsAffected = MyStoredProcedure();
//Print the value in the variable
Console.WriteLine(rowsAffected);
//Ideally, I want to perform the rollback here.
scope.Complete();
}
Is it enough to simple throw some sort of Exception or is there a better way to trigger a rollback?