This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I use a per-request unitOfWork and rely on LightSpeed to create this automatically . I dispose it on EndRequest. I have enclosed all my DB operations in a TransactionScope. Now I have one web page where TransactionScope does not work. The data gets written to the DB even when the transaction is not committed. I found that I can solve this problem by using the mechanism called "Using Standard .NET Transactions" in the LightSpeed Help file. If I use unitOfWork.BeginTransaction() instead of transactionScope then the code behaves correctly. Is this to be expected? Should I always use unitOfWork.BeginTransaction() in my application? I am using ASP.NET with MySQL. Thanks. |
|
|
TransactionScope support is database-dependent, but we use TransactionScope with MySQL in our automated tests and it seems to work fine (and, it sounds like it works for you on every other page). So it shouldn't be necessary to use BeginTransaction in preference to TransactionScope with MySQL (it *is* necessary with some other databases). LightSpeed never commits a TransactionScope as far as we know (it uses separate transactions if it needs to update a KeyTable, and again, if that were the issue I would expect it to happen on random pages rather than specifically on one page). I'd suggest stepping through that page's code to see if you can identify at what point the data gets saved: this should help track it down to either a rogue commit (if it happens after the SaveChanges) or to the TransactionScope perhaps not being set up somehow (if it happens during the SaveChanges). |
|
|
I stepped through the code and SaveChanges causes the data to be written to the DB directly. So it looks like the transactionscope is not being set up. The main difference between this page and the ones that work is that this page has a 3-way MultiView. It is a payment page and the user clicks OK three times, each time in a different View. I.e. Enter credit card number, enter address and confirm. The first 2 steps only read from the DB. The 3rd step reads and writes, using the standard construct:
using (TransactionScope ts = new TransactionScope()) { ...read and write to DB... } |
|