When using tableadapter to retrieve the data from database, Microsoft did not provide property to set command timeout anywhere, unless you go to generated file directly.
Once in XDataSet.Designer.cs file, there are 2 places that Command Timeout can be set:
1) On SelectCommand of Adapter itself - if this is for data retrieval calls, GetData method:
By default, no timeout is set, and default is 30 seconds.
Once in XDataSet.Designer.cs file, there are 2 places that Command Timeout can be set:
1) On SelectCommand of Adapter itself - if this is for data retrieval calls, GetData method:
this.Adapter.SelectCommand.CommandTimeout = 60;2) On initialization of command collection - each stored procedure call can have it's own command timeout.
this._commandCollection[0].CommandTimeout = 60;
By default, no timeout is set, and default is 30 seconds.
Nice pointer! Take care when editing a generated file - it might be a good idea to add a search/replace as a post-build step, or to use reflection from outside the generated code to get at the private _commandCollection member and set the timeout.
ReplyDeleteActually, turned out that there is a way to do it in the code behind of DataSet file, by using adapters.
ReplyDeleteSomething like this:
partial class MyDataTable
{
public static MyDataTable Load(Criteria criteria)
{
MyTableAdapter adapter = DataSqlAdaptersFactory.GetAdapter();
adapter.PublicCommandCollection[0].CommandTimeout = 0;
return adapter.LoadData(criteria);
}
} ...