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, I have been Light speed for quite sometime for normal CRUD operations its working really great !. I have a doubt about using SQL transaction with lightspeed. Do you support TRanscation command. I have acertain set of operation to be done which requires updation of more than 1 table hence, i want to make sure that the operation is successful only if insertion or updation on all the tables happens correctly otherwise it should just rollback. I am talking about the same SQL transaction command which does support commit and rollback. I did see BeginTransaction method from Unit of work which means lightspeed support transaction but then there are no save or add method from the class object. Could you please explain how can i make use of transaction . Any help would be useful.
Thanks, Savitha |
|
|
Yes, you can use IUnitOfWork.BeginTransaction or (for databases which support it) a .NET TransactionScope. You do not however save at the object level but rather at the unit of work level. This means you do not normally need a transaction because LightSpeed automatically puts a transaction around all of the inserts, updates and deletes within a single SaveChanges: uow.Add(new MyEntity()); But if you are doing multiple SaveChanges, or may need to roll back manually, you can do so: // BeginTransaction is similar |
|
|
Hi Ivan,
Thank you so much for your reply. I used Transaction as per your advice it did work good. I have one more problem.That is the operation fails if i use remove command within the transaction. It does work fine if i use only add and update commands. Do you have any idea about how to handle this? Waiting for your response. |
|
|
I'm not sure why you'd be seeing a problem using Remove() within a transaction. It should work fine. What error are you getting? |
|
|
Hi Ivan, Thank you again. I got it fixed, actual problem was i was opening two database connection under single transaction hence, there was a problem. I use to update record with connection and remove record under another connetion but both the operation was under single transactionscope(problem). Anyways now i use single connection under single transactionscope, in that way its working fine! Thank you for the quick response!
Thanks, Savitha |
|