all groups > dotnet component services > september 2005 >
You're in the

dotnet component services

group:

Design Question on Transaction Management


Design Question on Transaction Management jakk
9/21/2005 11:23:54 PM
dotnet component services: We have a situation when after user submits the page the data goes to 5
different stored procedures which are executed one after the other and
all these stored procedures should be in a one single transaction. My
question is where should I start the transactions, In the Business
Layer or in the DataAccess Layer. I was actually planning on creating a
method in DAL which calls the 5 methods which in turn call the 5 procs
and put this method in transaction using COM+. I dunno if this is a
good approach or should the transactions be handled in the Business
Layer. Is there any design pattern on this?? Does any one have any
sample code that I can use as a reference to handle transactions in
Business layer??

Thanks
Jak
Re: Design Question on Transaction Management Florin Lazar [MSFT]
10/1/2005 11:46:56 PM
Jak,

I don't know what is your definition for Business and DataAccess layers. If
I assume that your business layer is a layer between your client (web app)
and the DataAccess layer, then I can try to give an answer. The transaction
should be started at the level/layer where you needed. I.e. if in your
Business layer you have a method that calls two methods in the DataAccess
layer, and the actions of these methods should be transactional (all or
none) then you should start the transaction in the Business layer. If the
Business layer method only calls a method in DataAccess layer, which in turn
does 5 calls to the underlying database, then you should start the
transaction at the DataAccess level; no need to add the overhead of the
transaction flowing from the business layer to the dataAccess layer in this
case. I hope this answers your question.

Regards,
--
Florin Lazar - Microsoft - [ http://blogs.msdn.com/florinlazar ]
<Enjoy transactional programming with System.Transactions!>
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]
We have a situation when after user submits the page the data goes to 5
different stored procedures which are executed one after the other and
all these stored procedures should be in a one single transaction. My
question is where should I start the transactions, In the Business
Layer or in the DataAccess Layer. I was actually planning on creating a
method in DAL which calls the 5 methods which in turn call the 5 procs
and put this method in transaction using COM+. I dunno if this is a
good approach or should the transactions be handled in the Business
Layer. Is there any design pattern on this?? Does any one have any
sample code that I can use as a reference to handle transactions in
Business layer??

Thanks
Jak

AddThis Social Bookmark Button