繁体   English   中英

通过LINQ映射进行调用时增加SQL命令超时

[英]Increase SQL Command Timeout when making call through LINQ Mapping

这是我们用来获取数据库结果的方法:

[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.sp_calc_schedule_rates_retrieve")]
        public ISingleResult<sp_calc_schedule_rates_retrieveResult> sp_calc_schedule_rates_retrieve([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] System.Nullable<int> se_sched_id)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), se_sched_id);
            return ((ISingleResult<sp_calc_schedule_rates_retrieveResult>)(result.ReturnValue));
        }

使用此LINQ方法:

protected internal IExecuteResult ExecuteMethodCall(object instance, MethodInfo methodInfo, params object[] parameters);

在哪里可以增加SQL Command超时时间? 我们的proc的运行速度比平时慢,我想增加特定呼叫的超时时间,然后将其恢复为完成后的状态。 当我有一个SQLCommand对象时,我知道如何执行此SQLCommand ,但这正在通过LINQ进行,并且有些混乱。

您可以在OnCreated()内部设置DataContext类的CommandTimeout属性,如下所示:

partial void OnCreated()
{
    this.CommandTimeout = 3600; //value in seconds
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM