I've got to be missing something simple because I know this example works in C#. (I recently started a new job where they use VB.Net so I'm porting some code...)
I'm writing a simple unit test to demonstrate how esTransactions are used. This is using the Northwind database in SqlServer 2005. I'm creating a transaction and then changing the name of the first Category and the first Product. Then I dispose of the transaction object without calling the .Complete() method. This should undo the changes I made to the Category and the Product, but it's not.
I have tried this using two different methods as show below. I have the latest full (not trial) version of ES (1.5.3).
Code Set #1:
Dim _Category As Categories = New Categories()
_Category.LoadByPrimaryKey(1)
_Category.CategoryName = "BAD NAME"
Dim _Product As Products = New Products()
_Product.LoadByPrimaryKey(1)
_Product.ProductName = "BAD NAME"
Dim _Transaction As esTransactionScope = New esTransactionScope()
Try
With _Transaction
_Category.Save()
_Product.Save()
End With
Finally
CType(_Transaction, IDisposable).Dispose()
End Try
Code Set #2:
Dim _Category As Categories = New Categories()
_Category.LoadByPrimaryKey(1)
_Category.CategoryName = "BAD NAME"
Dim _Product As Products = New Products()
_Product.LoadByPrimaryKey(1)
_Product.ProductName = "BAD NAME"
Dim _Transaction As esTransactionScope = New esTransactionScope()
Try
_Category.Save()
_Product.Save()
Finally
CType(_Transaction, IDisposable).Dispose()
End Try
I also tried moving the Categories/Products declarations to after the Transaction declaration to no avail.
I also tried throwing an Exception at the end of the try but that didn't help either.
Any help would be greatly appreciated.
Thank you, David Burgett