1

我们正在使用 Nhibernate 连接到本地 firebird 数据库文件。我们目前加载它嵌入,但在某些情况下需要释放它,以便可以移动或删除磁盘上的文件。简单地在 nhibernate 中关闭和处理 sessionfactory 是行不通的。该文件仍在使用中。

using (ISessionFactory sessionFactory = configuration.BuildSessionFactory())
{
    using (ISession session = sessionFactory.OpenSession())
    {
        using (System.Data.IDbCommand command = session.Connection.CreateCommand())
        {
            // commands removed
        }
    }

    sessionFactory.Close();
}

// file is still "in use" here

这是可能的还是我们需要开始一个单独的过程?

4

1 回答 1

2

无需禁用池。我在我的许多项目中使用 NHibernate + FB Embedded。在代码中的适当位置尝试 FbConnection.ClearAllPools() (在您的情况下,似乎是在您使用完会话工厂之后)。您需要在项目中添加对 FB 提供程序程序集的引用。

于 2015-09-01T13:19:53.300 回答