C# DataExecutor class again
Creators & Contributors
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!
C# DataExecutor class again was originally published by Martin Paul Eve at eve.gd: Martin Paul Eve on July 31, 2008.
Files
10.59348_ker7b-4sd65.pdf
Files
(116.5 kB)
| Name | Size | Download all |
|---|---|---|
|
md5:6f06f85903ab04bb7abaa5e57461883e
|
116.5 kB | Preview Download |
Additional details
Description
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: Why do it like this? Answer: because it lets you hook into the return results for testing purposes.
Identifiers
- GUID
- https://doi.org/10.59348/ker7b-4sd65
- URL
- https://eve.gd/2008/07/31/c-dataexecutor-class-again/
Dates
- Issued
-
2008-07-31T00:00:00Z
- Updated
-
2008-07-31T05:33:04Z