I've been tasked to create a class that clients can use to get data from a specific data source. For example, the main routines will be
IDataReader GetDataReader(DbCommand command);
DataSet GetDataSet(DbCommand command);
I know that the Data Access Application block does this but I can't use the application block for reasons I won't explain. Anyway, I do plan to borrow some logic.
However, another part of my task is to keep track of open DataReaders. This is wanted just to verify everyone is closing their readers properly. My plan was to just have a collection of DataReaders inside this new class, that which will be added to each time the GetDataReader routine is called. At the end of the app's execution, the code will go through this collection and log warnings to a file for each reader that is still open.
So, I have 2 questions:
- Is there anything inherently wrong with this design?
- Is there anyway I can get the SQL command executed from the DataReader? This would greatly simplify the search for the un-closed reader. Or, do I have to store the reader/command pair to get this information?