Just been asked some further questions about the DataExecutor class on FreeNode and thought I'd give some usage instructions/clarification here.
Howto: Fill a strongly typed dataset
Set your base class (of your TableAdapter) to Tools.genericTableAdapter.
Fill your strongly typed DataSet thus:
DataExecutor de = null;
try{
de = new DataExecutor();
const string TABLEPREFIX = "blog";
MySqlCommand cmd = new MySqlCommand(string.Format("SELECT * FROM {0} WHERE id=@id", TABLEPREFIX));
cmd.Parameters.AddWithValue("@id", id);
de.NextCommand(cmd, false);
DataSchema.blog_postsDataTable postsDT = new DataSchema.blog_postsDataTable();
DataTable dtRef = (DataTable)postsDT;
de.DataSetSchema(ref dtRef);
} finally {
if(de != null) de.Close();
}
Why do it like this?
Answer: because it lets you hook into the return results for testing purposes.
de = new Tools.DataExecutor(true);
de.OnTestModeFill += new Tools.DataExecutor.TestModeFillInterceptor(taskFillHandler);
Then in taskFillHandler you will receive a reference to a DataTable that you can populate in whatever way you like to ensure that your application behaves correctly - aka. offline database unit testing!