transactionscope

How does TransactionScope roll back transactions?

两盒软妹~` 提交于 2019-11-26 05:20:03
问题 I\'m writing an integration test where I will be inserting a number of objects into a database and then checking to make sure whether my method retrieves those objects. My connection to the database is through NHibernate...and my usual method of creating such a test would be to do the following: NHibernateSession.BeginTransaction(); //use nhibernate to insert objects into database //retrieve objects via my method //verify actual objects returned are the same as those inserted

Get TransactionScope to work with async / await

六月ゝ 毕业季﹏ 提交于 2019-11-26 04:08:44
问题 I\'m trying to integrate async / await into our service bus. I implemented a SingleThreadSynchronizationContext based on this example http://blogs.msdn.com/b/pfxteam/archive/2012/01/20/10259049.aspx. And it works fine, except for one thing: TransactionScope . I await for stuff inside the TransactionScope and it break the TransactionScope . TransactionScope doesn\'t seems to play nice with the async / await , certainly because it store things in the thread using ThreadStaticAttribute . I get

SQL Server: Isolation level leaks across pooled connections

坚强是说给别人听的谎言 提交于 2019-11-26 03:35:32
问题 As demonstrated by previous Stack Overflow questions (TransactionScope and Connection Pooling and How does SqlConnection manage IsolationLevel?), the transaction isolation level leaks across pooled connections with SQL Server and ADO.NET (also System.Transactions and EF, because they build on top of ADO.NET). This means, that the following dangerous sequence of events can happen in any application: A request happens which requires an explicit transaction to ensure data consistency Any other

Under what circumstances is an SqlConnection automatically enlisted in an ambient TransactionScope Transaction?

删除回忆录丶 提交于 2019-11-26 02:59:32
问题 What does it mean for an SqlConnection to be \"enlisted\" in a transaction? Does it simply mean that commands I execute on the connection will participate in the transaction? If so, under what circumstances is an SqlConnection automatically enlisted in an ambient TransactionScope Transaction? See questions in code comments. My guess to each question\'s answer follows each question in parenthesis. Scenario 1: Opening connections INSIDE a transaction scope using (TransactionScope scope = new

TransactionScope automatically escalating to MSDTC on some machines?

眉间皱痕 提交于 2019-11-26 01:20:28
问题 In our project we\'re using TransactionScope\'s to ensure our data access layer performs it\'s actions in a transaction. We\'re aiming to not require the MSDTC service to be enabled on our end-user\'s machines. Trouble is, on half of our developers machines, we can run with MSDTC disabled. The other half must have it enabled or they get the \"MSDTC on [SERVER] is unavailable\" error message. It\'s really got me scratching my head and has me seriously considering rolling back to a home-spun