NHibernate transaction management in ASP.NET MVC - how should it be done?

Posted by adrin on Stack Overflow See other posts from Stack Overflow or by adrin
Published on 2010-04-05T22:55:50Z Indexed on 2010/04/05 23:23 UTC
Read the original article Hit count: 351

I am writing a simple ASP.NET MVC using session per request and transaction per request patterns (custom HttpModule). It seems to work properly, but.. the performance is terrible (a simple page loads ~7 seconds). For every http request, graphical resources incuding (all images on the site) a transaction is created and that seems to delay the loading times (without the transactions loading times per one image are ~1-10 ms with transactions they are over 1 second). What is the proper way to manage transactions in ASP.NET MVC + NH stack?

When i've put all transactions into my repository methods, for some obscure reasons I got 'implicit transactions' warning in NHProf (the SQL statements were executed outside transaction, even that in code session.Save()/Update()/etc methods were invoked within transaction 'using' scope and before transaction.Commit() call) BTW are implicit transactions really bad?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about ASP.NET