Search code examples
nhibernatefluent-nhibernate

How do I set the default transaction isolation level in Fluent NHibernate?


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.


Solution

  • With Fluent NHibernate v 2.x IsolationLevel() method can be used to globally set isolation level for transactions:

    MsSqlConfiguration.MsSql2008
        .IsolationLevel(System.Data.IsolationLevel.ReadCommitted)