【问题标题】:How do I set the command timeout using Massive ORM?如何使用 Massive ORM 设置命令超时?
【发布时间】:2011-10-19 18:22:34
【问题描述】:

如何使用 Massive ORM 设置命令超时属性?

【问题讨论】:

    标签: massive


    【解决方案1】:

    Massive 使用 System.Data.SqlClient 直接连接到 SQL Server。

    为了更改超时,您必须查看该文档。

    我修改了原来的 CreateCommand
    我所做的只是在第二行添加 result.CommandTimeout

     DbCommand CreateCommand(string sql, DbConnection conn, params object[] args)
        {
            var result = _factory.CreateCommand();
            result.CommandTimeout = 45;
            result.Connection = conn;
            result.CommandText = sql;
            if (args.Length > 0)
                result.AddParams(args);
            return result;
        }
    

    默认为 30 秒...

    类似的事情可以在 OpenConnection 中使用 ConnectionTimeout 完成

    【讨论】:

      猜你喜欢
      • 2012-05-17
      • 1970-01-01
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 1970-01-01
      • 2016-12-27
      • 2012-01-16
      • 1970-01-01
      相关资源
      最近更新 更多