how to move transaction from database layer to business layer?

how to move transaction from database layer to business layer?

Old forum URL: forums.lhotka.net/forums/t/2881.aspx


Jarvis posted on Wednesday, May 16, 2007

Hi, All

Firstly, Thanks CSLA team.

Now, I am try to use CSLA framework to build my new project. In my project these is parent(Member) table and Address children. From these days learnt, I know CSLA can do the transaction at database layer, but I still want to move it to the business layer, how to do? can you give me a example?

DansDreams replied on Wednesday, May 16, 2007

Are you saying you'd like your business object to be transactional - i.e. the business object and all its children would track the original values and have a mechanism of writing them back to the database if something went wrong?

But why?

Generally speaking, I think you need to let the database do what it does best and not mess with it.  If my description is correct, what are you going to do if there's a failure on one of the writes to reset to original values?  You're in deep trouble, whereas, in contrast, that is precisely the point of database transactions.

ajj3085 replied on Wednesday, May 16, 2007

I think what you'll want to do is use Clone to clone the BO you are to save, then call save on the clone.  If successfuly, you replace to original BO with the BO returned from the clones Save method.

Copyright (c) Marimer LLC