views:

259

answers:

1

I would like to set the default transaction level to ReadCommitted in my Fluent NHibernate configuration. If I were using XML mapping files, I could add a key to my config file:

<add key="hibernate.connection.isolation" value="ReadCommitted" />

but I can't figure out how to accomplish this with Fluent configuration.

+2  A: 

Fluent NHibernate doesn't do anything with the transaction isolation, so the default will be whatever NHibernate defaults to. I don't know off the top of my head what that is.

We don't have an explicit method to set the isolation, but as it's just a configuration value you can use the Raw method to set the property.

MsSqlConfiguration.MsSql2008.Raw("connection.isolation", "isolation_level");

Source: http://support.fluentnhibernate.org/discussions/help/45-default-isolation-level-for-transactions

Rafael Mueller
I found that too but it's not working for me. It is handling the setting because it throws an exception if I set it to an unsupported IsolationLevel (Chaos). But the profiler still shows the level as Unspecified unless I set it when beginning the transaction.
Jamie Ide
I'm not sure, but maybe the Unspecified on profiler just means that you didn't set any isolation level to this transaction, so nh will use the default one ?
Rafael Mueller