views:

1069

answers:

2

I am using the following generic code to save entities.

using (ITransaction tx = session.BeginTransaction())
{
    try
    {
       entity.DateModified = DateTime.Now;
       session.SaveOrUpdate(entity);
       session.Flush();
       tx.Commit();
       return entity;
    }
    catch (Exception)
    {
       tx.Rollback();
       throw;
    }
}

However, when I watch SQL Profiler I don't see any BEGIN TRANSACTION being sent to SQL Server. Is this normal, expected?

A: 

Try committing the transaction, then flushing the session.

madman1969
nope, same result.
Kyle West
+5  A: 

I'll suggest the obvious: make sure Profiler is set to display transaction information.

In the Trace Properties dialog -> Events selection tab, there's an expando for Transactions. Open it up and check the appropriate boxes (or just check 'em all on).

Also, FYI: I checked our application that uses NHibernate, and yes I do see BEGIN TRANSACTION and COMMIT TRANSACTION calls while tracing in Profiler.

Moskie
awesome answer. thanks. I never even knew that existed.
Kyle West