Is this a good solution to handle NHibernate Isession as PerWebRequest

北慕城南 提交于 2019-12-05 20:57:13
Paco

I use a unit of work, which I configure per web request in the container. The unit of work does not just create a session, but it also commits and rolls back transactions. The main reason to use a unit of work is to make the database more stable. More information about the unit of work pattern can be found on here.

public interface INHiberanteUnitOfWork
{
    ISession session { get; }
    void Commit();
    void RollBack();
}

I don't recommend any of those two solutions. Instead of trying to reinvent the wheel, use the NHibernate facility.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!