<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx</link><description>We’ve done some work with SqlClient’s System.Transaction support for Sql Server 2008. To explain what we did, and why, I’m going setup some background first, which may also be useful for understanding the existing behavior. System.Transactions offers</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>MSDN Blog Postings  &amp;raquo; Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8337185</link><pubDate>Wed, 26 Mar 2008 07:43:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8337185</guid><dc:creator>MSDN Blog Postings  » Extending Lightweight Transactions in SqlClient</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://msdnrss.thecoderblogs.com/2008/03/26/extending-lightweight-transactions-in-sqlclient/"&gt;http://msdnrss.thecoderblogs.com/2008/03/26/extending-lightweight-transactions-in-sqlclient/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8337810</link><pubDate>Wed, 26 Mar 2008 17:20:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8337810</guid><dc:creator>Nikolay Vasilyev</dc:creator><description>&lt;p&gt;There are several ways to handle this well known issue with transaction &amp;quot;auto-promotion&amp;quot; on second connection being opened. Like e.g. the one suggested by you with a ConnectionScope class (and the other developers like me create our own envelope classes to bind a TransactionScope instance with a SqlConnection instance).&lt;/p&gt;
&lt;p&gt;Should this new approach be somehow more convenient than ConnectionScope? Or is this just an alternative approach suitable for SQL Server 2008 only?&lt;/p&gt;
</description></item><item><title>re: Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8338065</link><pubDate>Wed, 26 Mar 2008 20:43:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8338065</guid><dc:creator>alazela</dc:creator><description>&lt;p&gt;I'd think a bit of both. &amp;nbsp;It's more convenient for a range of scenarios, but it is only suitable for use with SQL Server 2008. The scope-like pattern gives you more explicit control over which connection you are executing against and can guarantee you won't promote. But it does requires more rigor and writing more code (although that can generally be encapsulated).&lt;/p&gt;
&lt;p&gt;This extension will automatically kick in, even in places you did not (or possibly can not) add scope-like pattern support. Apps using the Visual Studio designer-generated data access patterns, apps using the DataAdapter.Fill()/Update() pattern without opening the connection first, and similar scenarios will gain the benefits.&lt;/p&gt;
</description></item><item><title>re: Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8343752</link><pubDate>Sat, 29 Mar 2008 23:51:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8343752</guid><dc:creator>Dennis van der Stelt</dc:creator><description>&lt;p&gt;AWESOME!!!!!!!!!!&lt;/p&gt;
&lt;p&gt;This was also a very good explanation. Thanks. Too bad it wasn't added to SQL2005 as Nikolay says, but it's in .NET 2.0 so it won't be changed easily. If it ain't broke, don't fix it, huh?! ;-)&lt;/p&gt;
&lt;p&gt;I've been waiting for this feature by the way. I've already updated the blogpost! :)&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://bloggingabout.net/blogs/dennis/archive/2007/06/28/system-transactions-still-not-working.aspx"&gt;http://bloggingabout.net/blogs/dennis/archive/2007/06/28/system-transactions-still-not-working.aspx&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>SqlClient, System.Transactions, SQL Server 2008, and MARS</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8361715</link><pubDate>Sun, 06 Apr 2008 02:07:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8361715</guid><dc:creator>Other Blogs we recommend (SSQA.net)</dc:creator><description>&lt;p&gt;It appears that there are some changes in .NET 3.5 System.Transactions (or System.Transactions.dll and&lt;/p&gt;
</description></item><item><title>re: Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8445472</link><pubDate>Thu, 01 May 2008 02:52:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8445472</guid><dc:creator>Josh Berke</dc:creator><description>&lt;p&gt;This is a great change in my opinion we went through the hastle of designing a fairly robust TransactionalContext that operated simillarly to both your ConnectionScope and to the System.Transactions TransactionScope. All to avoid promotion.&lt;/p&gt;
&lt;p&gt;I've just found your own ConnectionScope implementation, and I have one question / concern with it. I've read a lot about avoiding ThreadStatic variables when working in ASP.Net. Would you recommend your ConnectionScope in such a situation since it stores the Connection object in TLS? And if not are there any other alternatives?&lt;/p&gt;
&lt;p&gt;Thanks in advance.&lt;/p&gt;
&lt;p&gt;Josh&lt;/p&gt;
</description></item><item><title>Big Improvements in System.Data and SQL Server for Lightweight Transactions Support</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8452489</link><pubDate>Sat, 03 May 2008 02:07:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8452489</guid><dc:creator>Florin Lazar</dc:creator><description>&lt;p&gt;Great news! The new updates added to System.Data and SQL Server 2008 finally allow multiple Open/Close&lt;/p&gt;
</description></item><item><title>Lightweight Transactions in SQL Server 2008</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8457674</link><pubDate>Sun, 04 May 2008 08:57:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8457674</guid><dc:creator>Contagious Curiosity</dc:creator><description>&lt;p&gt;Good read which explains updates to SqlClient's System.Transactions in SQL Server 2008 which results&lt;/p&gt;
</description></item><item><title>re: Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8476748</link><pubDate>Fri, 09 May 2008 06:04:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8476748</guid><dc:creator>alazela</dc:creator><description>&lt;p&gt;Josh, I believe the issue with ThreadStatic fields and ASP.Net is due to lifetime management issues outside the scope of the creating code. The TransactionScope/ConnectionScope model avoids those issues by only using the ThreadStatic for nested call scopes, and removing their owned objects when control returns to the originating level.&lt;/p&gt;
</description></item><item><title>re: Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#8875930</link><pubDate>Mon, 18 Aug 2008 08:49:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8875930</guid><dc:creator>Martina</dc:creator><description>&lt;p&gt;We’ve done some work with SqlClient’s System.&lt;/p&gt;
</description></item><item><title>テーブルアダプタと TransactionScope の組み合わせ</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#9372386</link><pubDate>Fri, 23 Jan 2009 12:19:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9372386</guid><dc:creator>とあるコンサルタントのつぶやき</dc:creator><description>&lt;p&gt;さて、Silverlight 2 や WCF などの最新テクノロジの話ばっかりここまで書いてきたので、たまには地味（けれどもめちゃめちゃ重要）な話をひとつ書いてみたりします。結論を先に書くと、以下の通りです。&lt;/p&gt;
</description></item><item><title>re: Extending Lightweight Transactions in SqlClient</title><link>http://blogs.msdn.com/adonet/archive/2008/03/26/extending-lightweight-transactions-in-sqlclient.aspx#9894611</link><pubDate>Sun, 13 Sep 2009 08:08:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9894611</guid><dc:creator>JX</dc:creator><description>&lt;p&gt;Thanks for the good article. But I still have a few questions,&lt;/p&gt;
&lt;p&gt;1. &amp;quot;Resetting closes cursors, changes set options back to defaults, switches the database context back to the one from the connection string AND… rolls back any outstanding local transactions&amp;quot;&lt;/p&gt;
&lt;p&gt;here, you used &amp;quot;rolls back&amp;quot;, but later, you state: &amp;quot;When you close it’s outer connection, this inner connection is set aside pending the rollback or commit request&amp;quot;, &amp;nbsp;so I guess the first sentence is not accurate and exact.&lt;/p&gt;
&lt;p&gt;2. What will happen to the inner part of a closed connection in a transaction? will it just sleep there waiting for a final commit or rollback? or can already used by other threads? or it depends on whether the transaction is promoted later to a dtc one, if it's promoted, then it is no longer needed by the transaction, can be used by other threads, if not promoted to dtc transaction, then it will stay waiting and be not usalbe for other threads/transactions.&lt;/p&gt;
&lt;p&gt;The answer to question 2 will have an effect on coding pattern, if the inner part of a closed connection in a transaction is not needed any more, then closing it at the earlest possible time will release it for others to use, and will be a better coding pattern, if otherwise, then closing it later or after transaction commit or rollback will be a better coding pattern.&lt;/p&gt;
</description></item></channel></rss>