I have a DataSet with a QueriesTableAdapter. To control SqlCommand.CommandTimeout, I added a partial class called QueriesTableAdapter with the public ChangeTimeout method.
partial class QueriesTableAdapter { public void ChangeTimeout(int timeout) { foreach (System.Data.SqlClient.SqlCommand cmd in CommandCollection) { cmd.CommandTimeout = timeout; } } }
For each DataSet, I have a QueriesTableAdapter package, I can set CommandTimeout before execution.
using (NameSpace.DataSet.DataSetTableAdapters.QueriesTableAdapter ta = new NameSpace.DataSet.DataSetTableAdapters.QueriesTableAdapter()) { ta.ChangeTimeout(3600); ta.DoSomething(); }
This works well in most cases because the "QueriesTableAdapter" is named for you in the DataSet designer. The problem I am facing is TableAdapters, which are uniquely named. For example, if I have a DataTable called Person and a TableAdaper called PersonTableAdapter, I have to write a partial PersonTableAdapter class in the same way as I wrote the QueriesTableAdaper class. I have hundreds of DataTables with unique TableAdapter names. I do not want to create a partial class for each of them. How can I get to the base objects of the SqlCommand partial class in a global way?
source share