﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Yes, it would. And for a good reason.
  
You should manage your loading better. Transactions should be at the controller level, and scoped to include everything that goes on there.
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment13</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment13</guid><pubDate>Fri, 02 Jan 2009 08:00:21 GMT</pubDate></item><item><title>Tim Barcz commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>In the code:
  
  
using(var session = sessionFactory.OpenSession()) 
  
using(var tx = session.BeginTransaction()) 
  
{ 
  
	// execute code that uses the session 
  
	tx.Commit(); 
  
} 
  
  
Won't this disallow for lazy loading because the session will be gone when it leaves the scope of the "using"?
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment12</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment12</guid><pubDate>Fri, 02 Jan 2009 02:33:25 GMT</pubDate></item><item><title>Ayende Rahien commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Using DTC _is_ costly, and I wouldn't recommend it unless you are truly orchestrating several resources.
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment11</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment11</guid><pubDate>Thu, 01 Jan 2009 18:54:02 GMT</pubDate></item><item><title>Jan Van Ryswyck commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>In that case, I did something that made NH angry :-). I'm thinking about your advice to use a NH transaction for both read and write operations. This makes complete sense to me. 
  
  
However, I'm feeling a bit reluctant when it comes to TransactionScope as it can turn to distributed transactions without any transparent knowing from the developer. Using the DTC is rather costly I guess? 
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment10</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment10</guid><pubDate>Thu, 01 Jan 2009 18:51:04 GMT</pubDate></item><item><title>Ayende Rahien commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Jan,
  
Yes &amp; No.
  
It _sort of_ works in 2.0, if you don't do things that break it.
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment9</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment9</guid><pubDate>Thu, 01 Jan 2009 18:42:20 GMT</pubDate></item><item><title>Jan Van Ryswyck commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Isn't TransactionScope support only since NH 2.1?
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment8</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment8</guid><pubDate>Thu, 01 Jan 2009 18:37:00 GMT</pubDate></item><item><title>Ayende Rahien commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Not really.
  
When you Complete() the TransactionScope, NH will handle this for you
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment7</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment7</guid><pubDate>Wed, 31 Dec 2008 02:46:54 GMT</pubDate></item><item><title>Jack  commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>"call to Flush() is possible, but it is generally strongly discouraged, because this is usually a sign that you are not using transactions properly."
  
  
This is true if you're using NHibernate's transaction manager, but if we're using TransactionScope, we need to explicitly called Flush.
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment6</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment6</guid><pubDate>Mon, 29 Dec 2008 14:23:55 GMT</pubDate></item><item><title>Anders Lybecker commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Hi Oren,
  
  
I agree, as long as the transactions are kept short. Otherwise it is better to use implicit transactions for reading.
  
  
Another note about the transaction isolation level: I wouldn't call it optimization to reduce the isolation level - you have to think upfront about the use of isolation levels. 
  
In most cases when reducing isolation level, the cause is often nasty stuff like deadlocks etc.
  
  
Do consider readcommitted snapshot in SQL Server 2005+ when selecting transaction isolation level (similar to row versioning in the Oracle World which is default). 
  
 - 
[http://msdn.microsoft.com/en-us/library/tcbchxcb](http://msdn.microsoft.com/en-us/library/tcbchxcb)(VS.80).aspx
  
  
You should still keep your transactions short with readcommitted snapshot, otherwise you would be hammering the tempdb.
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment5</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment5</guid><pubDate>Mon, 29 Dec 2008 08:17:37 GMT</pubDate></item><item><title>Ayende Rahien commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>AndyK,
  
There is a difference between transactions and Unit of Work. A Unit of Work is usually composed of one or more transactions. This topic is focusing on something that is lower level than the unit of work.
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment4</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment4</guid><pubDate>Mon, 29 Dec 2008 06:00:00 GMT</pubDate></item><item><title>Ayende Rahien commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Steve,
  
Can you expand more about why you found this confusing and how I can make this less so?
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment3</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment3</guid><pubDate>Mon, 29 Dec 2008 05:58:59 GMT</pubDate></item><item><title>Andyk commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>Hi Oren,
  
in your last statement you recommend using x, y, z approaches. But does that mean then that you're now discouraging the unit of work pattern? Because you dont mention this at all? 
  
  
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment2</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment2</guid><pubDate>Sun, 28 Dec 2008 22:58:14 GMT</pubDate></item><item><title>Steve Bohlen commented on NH Prof Alerts: Use of implicit transactions is discouraged</title><description>To me this is a (somewhat) confusing section of the docs without an assumption that a reader already has a good understanding of the difference between an NHibernate transaction and a database transaction.
  
  
Recognizing that this is bound to be a recurring theme with this product (you will need to assume SOME level of base NH understanding else your recommended 'solutions' to the problems pointed out by the NH Profiler won't be comprehensible to users of the software), I wonder if this (transaction mgt) is an area that might be worth extrapolating on a bit to provide some more background....?
  
  
*I* got what you were saying, but I'm uncertain that other more 'casual' NH users necessarily would.
  
  
My $0.02.
</description><link>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment1</link><guid>http://ayende.com/3775/nh-prof-alerts-use-of-implicit-transactions-is-discouraged#comment1</guid><pubDate>Sun, 28 Dec 2008 20:35:06 GMT</pubDate></item></channel></rss>