NHibernate Current Session Context Problem

后端 未结 1 1808
滥情空心
滥情空心 2021-01-12 10:00

I\'ve recently moved from using an ISession directly to a wrapped ISession, Unit-of-Work type pattern.

I used to test this using SQL Lite (in-memory). I\'ve got a s

相关标签:
1条回答
  • 2021-01-12 10:07

    Try this:

    try
    {
        if (NHibernate.Context.CurrentSessionContext.HasBind(sessionFactory))
        {
            session = sessionFactory.GetCurrentSession();
        }
        else
        {
            session = sessionFactory.OpenSession(this.dateTimeInterceptor);
            NHibernate.Context.CurrentSessionContext.Bind(session);
        }
    }
    catch (Exception ex)
    {
        Debug.Write(ex.Message);
        throw;
    }
    
    0 讨论(0)
提交回复
热议问题