【问题标题】:Setting Linq to NHibernate ADO Command Timeout将 Linq 设置为 NHibernate ADO 命令超时
【发布时间】:2010-03-25 22:03:59
【问题描述】:

如何增加 NHibernate Linq To Sql 的超时时间?

不是连接超时,而是 ado 命令超时。

using (ISession session = NHibernateHelper.OpenSession(NHibernateHelper.Databases.CarrierCDR))
  using (session.BeginTransaction(IsolationLevel.ReadUncommitted))
  {
   lCdrs = (from verizon in session.Linq<Domain.Verizon>()
             where verizon.Research == true
             && verizon.ReferenceTable == null
             orderby verizon.CallBillingDate descending 
              select verizon).ToList();
}

【问题讨论】:

  • 有人能把这个问题的标题编辑成更具描述性的东西吗?

标签: c# nhibernate fluent-nhibernate linq-to-nhibernate command-timeout


【解决方案1】:

如果您正在使用 web.config 配置 NHibernate 会话,您可以将其添加到配置中:

<add key="hibernate.command_timeout" value="0" />

【讨论】:

  • 问题是在执行 Linq 查询时,该属性不用于实际命令。它总是在约 30 秒后超时。
【解决方案2】:

在所有 fluent nhibernate 的源代码中唯一提到命令超时参数的是FirebirdConfiguration 对象。它为您可能没有使用的 firebird 数据库配置应用程序。我建议使用您的配置对象,并咨询您的数据库的连接字符串参考。

PersistenceConfiguration 中的Raw 函数可以让您访问您正在寻找的属性,例如FirebirdConfiguration,您可以将Raw("command_timeout", "444"); 行添加到您配置nhibernate 的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-20
    • 2012-05-17
    • 1970-01-01
    • 2021-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多