From d1c8fb2ca22915dd42cf8229318b9538a8c2148b Mon Sep 17 00:00:00 2001 From: Tim Iles Date: Mon, 8 Dec 2014 16:11:27 +0000 Subject: [PATCH] Test for transaction rollback on procedure with specified schema Hi, We are experiencing an issue with rolling back a transaction which executes a stored procedure in a schema other than dbo. I have created a test that reproduces the issue: even if the schema is dbo, by specifying it explicitly we lose the transaction. I followed the code through as far as DynamicSchema.TryInvokeMember calling command.Execute without passing any transaction? That's as far as I got, but I could be going down completely the wrong rabbit hole... I'd be happy to (try to) help further if you agree this is in need of fixing! Tim --- Simple.Data.SqlTest/TransactionTests.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Simple.Data.SqlTest/TransactionTests.cs b/Simple.Data.SqlTest/TransactionTests.cs index d25ef1ae..cea35a9e 100644 --- a/Simple.Data.SqlTest/TransactionTests.cs +++ b/Simple.Data.SqlTest/TransactionTests.cs @@ -55,6 +55,27 @@ public void TestRollback() Assert.AreEqual(1, db.OrderItems.All().ToList().Count); } + [Test, Ignore("TODO: fix transactions?")] + public void TestRollbackOnProcedureWithSpecifiedSchema() + { + var db = DatabaseHelper.Open(); + + int customerId; + using (var tx = db.BeginTransaction()) + { + var customer = tx.dbo.CreateCustomer().FirstOrDefault(); + customerId = customer.CustomerId; + + var customerBeforeRollback = db.Customers.FindByCustomerId(customerId); + Assert.IsNotNull(customerBeforeRollback); + + tx.Rollback(); + } + + var customerAfterRollback = db.Customers.FindByCustomerId(customerId); + Assert.IsNull(customerAfterRollback); + } + [Test] public void TestWithOptionsTransaction() {