Correct use of the NHibernate Unit Of Work pattern and Ninject

前端 未结 3 800
余生分开走
余生分开走 2020-12-07 22:17

I have the following implementation and would like some feedback as to whether it makes correct use of NHibernate for sessions and transactions.

public inter         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 22:47

    An important part of the answer lies in what you want your transaction sizes to be. Right now (as jeroenh has indicated) the transaction is per method invocation on your repository. This is very small and probably not needed. I created an ASP.MVC application and it uses a transaction size that included everything from a single http request. This could be multiple database reads/updates. I am using the same unit of work and Ninject for IOC. Take a look, maybe something will help with your issues:

    http://bobcravens.com/2010/06/the-repository-pattern-with-linq-to-fluent-nhibernate-and-mysql/

    http://bobcravens.com/2010/07/using-nhibernate-in-asp-net-mvc/

    http://bobcravens.com/2010/09/the-repository-pattern-part-2/

    http://bobcravens.com/2010/11/using-ninject-to-manage-critical-resources/

    Hope this helps.

    Bob

提交回复
热议问题