C# 通过LINQ映射进行调用时增加SQL命令超时
下面是我们调用以获取DB结果的方法:C# 通过LINQ映射进行调用时增加SQL命令超时,c#,.net,linq,sql-server-2008,C#,.net,Linq,Sql Server 2008,下面是我们调用以获取DB结果的方法: [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.Ma
[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));
}
在哪里可以增加SQL命令超时?我们的进程运行得比平时慢,我想增加特定调用的超时时间,然后在完成后恢复到原来的状态。当我有一个
SQLCommand
对象时,我知道如何执行此操作,但这是经过LINQ处理的,有点混乱。您可以在OnCreated()内设置DataContext类的CommandTimeout属性,如下所示:
partial void OnCreated()
{
this.CommandTimeout = 3600; //value in seconds
}
我认为调整proc是更好的选择。
partial void OnCreated()
{
this.CommandTimeout = 3600; //value in seconds
}