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
|
Hi guys, Quick question. I'm just reviewing some of my older code that I wrote against LS1.2 and was curious whether I really needed to wrap some of my persistance methods in a TransactionScope? I noticed this statement in the help docs... LightSpeed ensures that all database flush operations run within a transaction. So does this mean that TransactionScope is superfluous if I only have a single UOW.SaveChanges() call within a given business transaction. I have seen you mention TransactionScope in the forums - would transaction scope only be of use if you were making a complex set of multiple calls to UOW.SaveChanges() and you want all of the statements within the multiple calls to be atomic? Thanks for your time, Cheers, Greg |
|
|
Correct. SaveChanges checks for a transaction already in progress (whether an ADO.NET transaction on the connection, or an ambient TransactionScope-style transaction). If there is a transaction in progress, SaveChanges runs within that transaction (and the transaction remains pending). If there is no transaction in progress, SaveChanges internally initiates a transaction, does its work, and commits the transaction. Therefore you would need to use your own transaction only if you wanted to perform multiple SaveChanges transactionally, or to enlist other resources (e.g. a message queue -- or even another database) in the same transaction, or wanted to be able to roll back the changes for some reason (e.g. in testing code, or if you wanted the commit to depend on some additional external condition). |
|
|
Hi Ivan, Thanks for the confirmation. I haven't seen the LS documentation for the more recent versions of the product, but if they don't include the above information, can I suggest you add an abridged version of the above to the product doco... Cheers, Greg |
|