English 中文(简体)
Transactions in .Net 2.0 application-- what to use?
原标题:

I m working on a .Net 2.0 application and need to wrap some database transactions in my code. The backend is SQL Server 2008.

I ve been away from .net for a few years, the last time I did any transaction processing was in .Net 1.1 with serviced components. I know about TransactionScope, and was wondering if that s a good way to go about things now.

Also, in .Net 3.5 I assume there are other ways to do this, say with WCF? Just wondering if someone could point me toward an article or two. Thanks very much.

最佳回答

TransactionScope is a good way, provided you keep it in check. All ADO.Net providers are aware of the System.Transactions objects so they will enlist properly into a back end transaction when operating under a TransactionScope.

There are two gotchas:

. You can determine the isolation level of an existing transaction using the IsolationLevel property of a transaction.

  • Distributed transactions. Whithin a transaction scope the moment you use a second ADO.Net connection the TransactionScope will enlist it, together with the first one, into a distributed transaciton, even when both transacitons point to the same database. Make sure you use one and only one connection within a transaciton scope.

Technically the last point applies to using any resource manager, but is unlikely you ll use any other RM than your db connections. IF you do, then enlisting into a distributed transaction is the proper action anyway.

问题回答

暂无回答




相关问题
Autopaging or custom paging which is better in datagrid?

i used datagrid control in .net platform... but now i am in big confusion .. that is ..which is better to used custom or autopaging option.. gud explaination or example is needed.. i dont know ...

Gridview item preview using .net 2.0

I have a GridView control that for each item has a Hyperlinkfield with a URL to an aspx page. I want to (using AJAX libraries) to display the page preview in an inline window as the user hovers over ...

Rendering form to bitmap

I would like to render Form to bitmap... Is it possible in .net 2.0?

Transactions in .Net 2.0 application-- what to use?

I m working on a .Net 2.0 application and need to wrap some database transactions in my code. The backend is SQL Server 2008. I ve been away from .net for a few years, the last time I did any ...

Subsonic query: issue with the produced query

I m having a problem with subsonic query. The deal is, I have a view and I want to query it s data to produce something like the following SQL statement: select * from myView where (col1 like %a% ...

热门标签