slandau
slandau

Reputation: 24052

Increase SQL Command Timeout when making call through LINQ Mapping

Here is the method we call to get the DB results:

[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));
        }

Uses this LINQ method:

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

Where can I increase the SQL Command timeout? Our proc has been running slower then usual and I want to increase the timeout for specific calls, and then put it back to what it was after it's done. I know how to do this when I have a SQLCommand object, but this is going through LINQ and a little confusing.

Upvotes: 3

Views: 4411

Answers (1)

You can set the CommandTimeout property of the DataContext class, inside of OnCreated(), like this:

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

Upvotes: 2

Related Questions