Hello,
I have a simple unit test which is failing the final assertion:
[TestMethod] public void ExecuteNonQueryWithCommand_ShouldUseTransaction() { const string insertString = "insert into Region values (77, 'Elbonia')"; const string countString = "select count(*) from Region"; const string deleteString = "delete from Region where RegionId = 77"; TdConnection cn = new TdConnection(db.ConnectionString); cn.Open(); TdCommand insertCmd = new TdCommand(insertString, cn); TdCommand countCmd = new TdCommand(countString, cn); TdCommand deleteCmd = new TdCommand(deleteString, cn); int initialRows = (int)countCmd.ExecuteScalar(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { int rows = insertCmd.ExecuteNonQuery(); Assert.AreEqual(1, rows); } int postScopeRows = (int)countCmd.ExecuteScalar(); deleteCmd.ExecuteNonQuery(); cn.Close(); Assert.AreEqual(initialRows, postScopeRows); }
I was under the impression per this MSDN documentation linked below (see the remarks section) that the transaction should roll back due to the lack of a scope.Complete() statement within the using block. Does Teradata support this feature?
http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope(v=vs.110).aspx
Tags:
Forums: