【发布时间】:2023-03-18 10:43:01
【问题描述】:
我们正在使用 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
这是否可行,或者我们是否需要启动一个单独的流程?
【问题讨论】:
-
我相信 Firebird .net 提供程序池连接,所以你需要从池中释放连接。
-
感谢您的评论。我将尝试在 nhibernate 中更改发布模式,看看是否可行。 (nhibernate.info/doc/nh/en/…)
-
不确定这是否会有所帮助,是 Firebird 驱动程序本身进行了池化。您可以尝试禁用连接池(即:将
Pooling=false添加到连接字符串)。
标签: c# nhibernate firebird firebird2.5 firebird-embedded