Hi,
I was playing around with TransactionScope in my Hibernate Repository
and came up with this simple change:
>From this:
NHibernateSessionManager.Instance.BeginTransaction();
try
{
Session.Flush();
NHibernateSessionManager.Instance.CommitTransaction();
}
catch (Exception)
{
NHibernateSessionManager.Instance.RollbackTransaction
();
throw;
}
To This:
using (TransactionScope ts = new TransactionScope())
{
Session.Flush();
ts.Complete();
}
The latter seems so much easier, will pick up any existing
transactions (we do a not of integrating NHibernate with Linq-SQL,
NHibernate with MSMQ etc.) I think, and seems to work ok in basic
single database tests. My Session Mode used to be set to Commit but
now is set to Never.
However, there must be a gotcha with this.. What is it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---