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, sorry, but I couldn't find a definitive answer as to whether "SaveChanges" always runs in it's own transaction (assuming no TransactionScope has been used anywhere).
|
|
|
You do not need to create a transaction. SaveChanges will create a transaction if there isn't one already in progress, and all the SQL statements that comprise the SaveChanges will run in that transaction. But of course this will encompass only the work that is done as part of that single SaveChanges call, and is automatically committed unless an error occurs during the SaveChanges. The documentation that recommends using a TransactionScope isn't meant to be implying that you should always create your own TransactionScope. The intent is more along the lines of: *If* you need your own transaction (for example, because you're doing multiple SaveChanges, or need to be able to control commit or rollback based on your own application logic), *then* TransactionScope is the recommended way to go. Does that make a bit more sense? We'll try to clarify this in a future release. |
|
|
Yes, thanks Ivan - that makes perfect sense - excellent explanation |
|