<?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>A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx</link><description>I’ve heard a few comments from people who would like an easier way to manage connection lifetime &amp;amp; use across multiple methods. Most often, the problem is due to using a TransactionScope at an higher level, but opening and closing connections inside</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Transa</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#532195</link><pubDate>Wed, 15 Feb 2006 03:38:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:532195</guid><dc:creator>Israel A</dc:creator><description /></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#538743</link><pubDate>Fri, 24 Feb 2006 20:42:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:538743</guid><dc:creator>DonM</dc:creator><description>This looks like a perfect answer to a problem I'm solving with our web site. I do have a question. The empty loop looks like a potentially infinite loop, for example, if _priorScope is disposed. Your code at line 124 is:&lt;br&gt;&lt;br&gt;DbConnectionScope prior = _priorScope;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while (null != prior &amp;amp;&amp;amp; _priorScope.IsDisposed) {&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Intentionally empty loop&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br&gt;&lt;br&gt;I think it should be&lt;br&gt;DbConnectionScope prior = _priorScope;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while (null != prior &amp;amp;&amp;amp; prior.IsDisposed) {&lt;br&gt;prior = prior._priorScope; // Try the next nested scope.&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br&gt;&lt;br&gt;Do you agree or is there something I'm missing?</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#538811</link><pubDate>Fri, 24 Feb 2006 22:52:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:538811</guid><dc:creator>alazela</dc:creator><description>You are absolutely correct, the loop shouldn't be empty. Serves me right for anticipating a problem, then not actually testing my solution. :-)&lt;br&gt;&lt;br&gt;Thanks for catching this -- I'll patch the class and update the attachment.</description></item><item><title>A Customization of ConnectionScope</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#539548</link><pubDate>Mon, 27 Feb 2006 00:05:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:539548</guid><dc:creator>DonM</dc:creator><description>Using your ConnectionScope class as a starting point I've solved a bunch of problems for our web project.&lt;br&gt;&lt;br&gt;I'm building a typical web site using a single database and a common connection pool for all users. I have a DataAccess static class based on the MS Data Access Application Block published for .Net 1.1. It has a static connection string so all requests use the same connection string and connection pool.&lt;br&gt;&lt;br&gt;When saving a single business object, autocommit works fine and life is simple. When saving multiple business objects, I need to have them all work or all roll back. I don't want to consume db connections; I want everything from a single request to use no more than one connection.&lt;br&gt;&lt;br&gt;I removed your dictionary of connections and have only a single connection reference (which can be null). In my DataAccess class, I check to see if I'm in a ConnectionScope. If I am, I try to get a connection from it. If it doesn't have one, I create a connection and set the ConnectionScope's Connection property with it so it's available later to be resused. I use the connection for the requested query.&lt;br&gt;&lt;br&gt;When a new ConnectionScope is created, it checks to see if it is nested. If so, it copies the Connection reference from the outer scope so it will be reused without consuming another connection. Null does no harm.&lt;br&gt;&lt;br&gt;When a nested ConnectionScope is disposed, if it has a Connection and the new current ConnectionScope doesn't have one, the disposing nested scope gives its connection to the new (outer) current scope, again so the same connection is reused. This handles the case of (1) Create scope1; (2) Create scope2; (3) Do Query3; (4) End scope2; (5) Do Query4; (6) End Scope1. Query4 will use the same connection created by Query3.&lt;br&gt;&lt;br&gt;When the last ConnectionScope is disposed (having no parent), it disposes the Connection it has (if it has one). This ensures the connection gets closed, returned to the pool, and can be reused for another request.&lt;br&gt;&lt;br&gt;Thanks for publishing ConnectionScope which showed me an elegant way of transactionfying my application without forcing the application code to deal with database connections or database transactions.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#539944</link><pubDate>Mon, 27 Feb 2006 19:34:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:539944</guid><dc:creator>alazela</dc:creator><description>I'm glad to hear it's useful to you! &amp;nbsp;That always makes my day. :-) &amp;nbsp;It sounds like you've come up with a nice customization to match your particular needs.&lt;br&gt;&lt;br&gt;There were actually a couple of enhancements I have been thinking about, but didn't implement due to time and trying to keep the idea mostly simple. &amp;nbsp;One was scope nesting options similar to System.Transactions.TransactionScopeOptions. &amp;nbsp;A &amp;quot;Requires&amp;quot; option would also handle the basics of your scenario, where the inner scope would not even hook itself into the chain upon detecting the presense of an outer scope.</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#543526</link><pubDate>Sat, 04 Mar 2006 12:09:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:543526</guid><dc:creator>jherbst</dc:creator><description>Thanks for this usefull class!&lt;br&gt;I als need transactions over more then one business object and with TransactionScope() I found a way to simply implement it in .Net 2.0.&lt;br&gt;&lt;br&gt;With your class I thought I can reuse one connection over more then one dataoperations but it seems there are a few points we have to take care:&lt;br&gt;-) The connection need to be created outside (!) the first transactionscope.&lt;br&gt;As soon as you try to create the connection inside the transactionscope-statement ADO.Net tries to use MSDTC (and if you turn of MSDTC-Service you get a exception on result.Open()-statement)!&lt;br&gt;&lt;br&gt;In this following sample it is working without using MSDTC:&lt;br&gt;&lt;br&gt;DBDataAccessLayer da = DataAccessLayerHelper.GetDBLayer();&lt;br&gt;using (DbConnectionScope dbScope = new DbConnectionScope()) {&lt;br&gt;	DbConnectionScope.Current.GetOpenConnection(da.DBProvider, da.ConnectionStringSettings.ConnectionString);&lt;br&gt;	using (TransactionScope scope = new TransactionScope()) {&lt;br&gt;	&lt;br&gt;		// some BLL operations &lt;br&gt;		&lt;br&gt;		scope.Complete();&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;&lt;br&gt;-) I did some change on your source-code do support nested DBConnectionScope-statements.&lt;br&gt;&lt;br&gt;With these changes I am able to reuse an open connection and it is guaranteed that there is only one connection open to the database inside the top spanning DB-scope:&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;#region class fields&lt;br&gt;[ThreadStatic()]&lt;br&gt;private static DbConnectionScope __currentScope = null; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Scope that is currently active on this thread&lt;br&gt;private static Object __nullKey = new Object(); &amp;nbsp; // used to allow null as a key&lt;br&gt;// jherbst: moved to static because this component should reuse an open connections from stack&lt;br&gt;private static Dictionary&amp;lt;object, DbConnection&amp;gt; _connections; &amp;nbsp; // set of connections contained by this scope.&lt;br&gt;#endregion&lt;br&gt;&lt;br&gt;#region instance fields&lt;br&gt;private DbConnectionScope _priorScope; &amp;nbsp; &amp;nbsp;// previous scope in stack of scopes on this thread&lt;br&gt;#endregion&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;public DbConnectionScope() {&lt;br&gt;	// Devnote: &amp;nbsp;Order of initial assignment is important in cases of failure!&lt;br&gt;	// &amp;nbsp;_priorScope first makes sure we know who we need to restore&lt;br&gt;	// &amp;nbsp;_connections second, to make sure we no-op dispose until we're as close to&lt;br&gt;	// &amp;nbsp; &amp;nbsp; &amp;nbsp;correct setup as possible&lt;br&gt;	// &amp;nbsp;__currentScope last, to make sure the thread static only holds validly set up objects&lt;br&gt;	_priorScope = __currentScope;&lt;br&gt;	// jherbst: only if _connections is null a new dictionary object should be created.&lt;br&gt;	if (_connections == null)&lt;br&gt;		_connections = new Dictionary&amp;lt;object, DbConnection&amp;gt;();&lt;br&gt;	__currentScope = this;&lt;br&gt;}		&lt;br&gt;&lt;br&gt;public void Dispose() {&lt;br&gt;	if (!IsDisposed) {&lt;br&gt;		// Firstly, remove ourselves from the stack (but, only if we are the one on the stack)&lt;br&gt;		// &amp;nbsp;Note: Thread-local _currentScope, and requirement that scopes not be disposed on other threads&lt;br&gt;		// &amp;nbsp; &amp;nbsp; &amp;nbsp;means we can get away with not locking.&lt;br&gt;		if (__currentScope == this) {&lt;br&gt;			// In case the user called dispose out of order, skip up the chain until we find&lt;br&gt;			// &amp;nbsp;an undisposed scope.&lt;br&gt;			DbConnectionScope prior = _priorScope;&lt;br&gt;			while (null != prior &amp;amp;&amp;amp; _priorScope.IsDisposed) {&lt;br&gt;				prior = prior._priorScope;&lt;br&gt;			}&lt;br&gt;			__currentScope = prior;&lt;br&gt;		}&lt;br&gt;&lt;br&gt;		// jherbst: &lt;br&gt;		// added check to see if __currentscope is null (the last scope on the stack)&lt;br&gt;		// if so, dispose all and close the open connections&lt;br&gt;		if (__currentScope == null) {&lt;br&gt;			// secondly, make sure our internal state is set to &amp;quot;Disposed&amp;quot;&lt;br&gt;			IDictionary&amp;lt;object, DbConnection&amp;gt; connections = _connections;&lt;br&gt;			_connections = null;&lt;br&gt;&lt;br&gt;			// Lastly, clean up the connections we own&lt;br&gt;			foreach (DbConnection connection in connections.Values) {&lt;br&gt;				connection.Dispose();&lt;br&gt;			}&lt;br&gt;		}&lt;br&gt;&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;&lt;br&gt;May it make sense to inlude some &amp;nbsp;kind of TransactionScopeOptions like you mention above to be able to open a new connection inside a DBScope.&lt;br&gt;</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#546512</link><pubDate>Thu, 09 Mar 2006 00:14:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:546512</guid><dc:creator>alazela</dc:creator><description>One thing you need to watch out for with the changes you've made is that the class is no longer safe to use in a multi-threaded app. &amp;nbsp;By making the dictionary a static field, all threads using a DbConnectionScope within the appdomain will attempt to use the same instance of dictionary. &amp;nbsp;Dictionaries and SqlConnections are not thread safe for general use, so you can easily end up corrupting their state. &amp;nbsp;Even if you add a lock on the dictionary while accessing it, you end up having difficult-to-understand semantics about WHEN the connections are closed (__currentScope is still a thread static, so you have multiple stacks of scopes, each of which wants to close the connections when the last one in it's stack is disposed).&lt;br&gt;&lt;br&gt;Remember to be wary when adding static fields to any code!&lt;br&gt; </description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#548421</link><pubDate>Fri, 10 Mar 2006 15:05:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:548421</guid><dc:creator>jherbst</dc:creator><description>Thanks for your comment, you are right!&lt;br&gt;&lt;br&gt;I just changed the DBConnectionscope class so that it will use a stack object to manage nested ConnectionScopes better (this stack object is stored ThreadStatic).&lt;br&gt;&lt;br&gt;The connection-object is now a instance variable again so there should be no issue with multithreaded access.&lt;br&gt;</description></item><item><title>System.Transactions : Promotable Enlistment</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#555956</link><pubDate>Tue, 21 Mar 2006 00:35:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:555956</guid><dc:creator>Dennis van der Stelt</dc:creator><description>In two previous posts, I told how great the TransactionScope of the System.Transactions namespace is....</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#571606</link><pubDate>Sat, 08 Apr 2006 20:52:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:571606</guid><dc:creator>Eric Popivker</dc:creator><description>Hi Alazel,&lt;br&gt;&lt;br&gt;Thank you for a great class. &amp;nbsp;I am currently working on a similar class that will scope both Open Connection and Transaction at the same time - basically combine the two 'using' statements into one. &amp;nbsp;I have several questions about ADO.NET and DbConnectionScope:&lt;br&gt;&lt;br&gt;1. &amp;nbsp;What are the disadvantages of distributed transaction over multiple open connections versus one transaction over a single connection? &amp;nbsp;Is there a big performance hit?&lt;br&gt;&lt;br&gt;2. &amp;nbsp;I know .NET framework pools open connections, so does keeping an open connection still make an application more efficient?&lt;br&gt;&lt;br&gt;For example is there a big difference between:&lt;br&gt;&lt;br&gt;DbConnection cn1=CreateOpenCn();&lt;br&gt;RunSomeQuery1(cn1);&lt;br&gt;cn1.Close()&lt;br&gt;&lt;br&gt;DbConnection cn2=CreateOpenCn();&lt;br&gt;RunSomeQuery2(cn2);&lt;br&gt;cn2.Close();&lt;br&gt;&lt;br&gt;VS&lt;br&gt;&lt;br&gt;DbConnection cn=CreateOpenCn();&lt;br&gt;RunSomeQuery1(cn);&lt;br&gt;RunSomeQuery2(cn);&lt;br&gt;cn.Close();&lt;br&gt;&lt;br&gt;3. &amp;nbsp;Is there a big difference between nesting multiple TransactionScopes vs re-using the same TransactionScope, assuming both use the same open connection. &amp;nbsp;Theoretically it should be pretty much the same. &amp;nbsp;I usually like to re-use whatever objects I already instantiated, but not sure if in this case it is worth the effort.&lt;br&gt;&lt;br&gt;4. In the new version of your DbConnectionScope class, in what cases you would use options 'NewRequired' and 'Suppress'? &amp;nbsp; I tried to think of cases when I would not want to re-use already open connection, but could not think of any. &amp;nbsp;&lt;br&gt;&lt;br&gt;Thanks ahead for your time.&lt;br&gt;&lt;br&gt;Best Regards</description></item><item><title>RAD for N-Tier web apps in .NET  &amp;raquo; Blog Archive   &amp;raquo; Connection/Transaction scope</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#572602</link><pubDate>Mon, 10 Apr 2006 19:57:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:572602</guid><dc:creator>RAD for N-Tier web apps in .NET  » Blog Archive   » Connection/Transaction scope</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://xlib.wordpress.com/2006/04/10/connectiontransaction-scope/"&gt;http://xlib.wordpress.com/2006/04/10/connectiontransaction-scope/&lt;/a&gt;</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#588347</link><pubDate>Tue, 02 May 2006 16:55:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:588347</guid><dc:creator>Jenser</dc:creator><description>Hi Alazel,&lt;br&gt;&lt;br&gt;Nested connection scope is merged in this code?</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#625393</link><pubDate>Sat, 10 Jun 2006 19:37:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:625393</guid><dc:creator>Remy</dc:creator><description>I must say I'm extremely disappointed in this LTM limitation. &amp;nbsp;The instant I read about DTC promotion, I wondered whether the System.Transactions would be smart enough to create a subpool bound to the 'lightweight' transaction. &amp;nbsp;Apparently not. &amp;nbsp;This basically renders the LTM useless to anything but &amp;nbsp;the degenerate case of one object, where I might just as easily use a SqlTransaction. &amp;nbsp;Jeez...&lt;br&gt;</description></item><item><title>re: A ConnectionScope class. [Alazel Acheson]</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#642487</link><pubDate>Thu, 22 Jun 2006 10:18:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:642487</guid><dc:creator>Oren Ellenbogen</dc:creator><description>It seems that this class isn't thread-safe or maybe I'm doing something wrong here:&lt;br&gt;&lt;br&gt;class Program&lt;br&gt; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;static void Main(string[] args)&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;using (DbConnectionScope conn = new DbConnectionScope())&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(new Thread(RunQuery)).Start();&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(new Thread(RunQuery)).Start();&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private static void RunQuery()&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string ConnectionString = ConfigurationManager.AppSettings[&amp;quot;DBConnection&amp;quot;];&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SqlCommand cmd = new SqlCommand(&amp;quot;Select * from E_Products&amp;quot;);&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cmd.Connection = (SqlConnection)DbConnectionScope.Current.GetOpenConnection(SqlClientFactory.Instance, ConnectionString);&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DataTable table = new DataTable();&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DateTime start = DateTime.Now;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;using (SqlDataReader reader = cmd.ExecuteReader())&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;table.BeginLoadData();&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;table.Load(reader);&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;table.EndLoadData();&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TimeSpan span = DateTime.Now - start;&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;Loading time: &amp;quot; + span.Milliseconds);&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;Rows count: &amp;quot; + table.Rows.Count);&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br&gt; &amp;nbsp; &amp;nbsp;}&lt;br&gt;&lt;br&gt;Running this code will result with &amp;quot;NullReferenceExpcetion&amp;quot; on the GetOpenConnection line.&lt;br&gt;&lt;br&gt;Am I missing something here ?&lt;br&gt;</description></item><item><title>ADO.Entity Framework: Stored Procedure Customization</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#8338149</link><pubDate>Wed, 26 Mar 2008 21:24:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8338149</guid><dc:creator>meek</dc:creator><description>&lt;p&gt;The ADO.NET Entity Framework (EF) allows you to map stored procedures to functions that return typed&lt;/p&gt;
</description></item><item><title>Tony and Zuzana&amp;#8217;s World &amp;raquo; System.Transactions and the DTC</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#8399046</link><pubDate>Wed, 16 Apr 2008 17:37:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8399046</guid><dc:creator>Tony and Zuzana&amp;#8217;s World &amp;raquo; System.Transactions and the DTC</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blog.tonysneed.com/?p=63"&gt;http://blog.tonysneed.com/?p=63&lt;/a&gt;&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/dataaccess/archive/2006/02/14/532026.aspx#8452488</link><pubDate>Sat, 03 May 2008 02:07:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8452488</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>SQL Tidbits  &amp;raquo; Blog Archive   &amp;raquo; How to keep a transaction from being escalated to the DTC</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#9245832</link><pubDate>Mon, 22 Dec 2008 00:01:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9245832</guid><dc:creator>SQL Tidbits  &amp;raquo; Blog Archive   &amp;raquo; How to keep a transaction from being escalated to the DTC</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://sql-tidbits.lincoln.se/2008/12/21/how-to-keep-a-transaction-from-being-escalated-to-thedtc/"&gt;http://sql-tidbits.lincoln.se/2008/12/21/how-to-keep-a-transaction-from-being-escalated-to-thedtc/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Data Access blog A ConnectionScope class Alazel Acheson | Outdoor Ceiling Fans</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#9669346</link><pubDate>Sun, 31 May 2009 16:17:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9669346</guid><dc:creator> Data Access blog A ConnectionScope class Alazel Acheson | Outdoor Ceiling Fans</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://outdoorceilingfansite.info/story.php?id=5159"&gt;http://outdoorceilingfansite.info/story.php?id=5159&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Store commands</title><link>http://blogs.msdn.com/dataaccess/archive/2006/02/14/532026.aspx#9723426</link><pubDate>Wed, 10 Jun 2009 09:13:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9723426</guid><dc:creator>VS2010学习</dc:creator><description>&lt;p&gt;You can reuse the connection on an ObjectContext to create a store command as follows: using (MyContext&lt;/p&gt;
</description></item></channel></rss>