We all know that DataReaders are quicker than DataTables since the a DataReader is used in the construction of a DataTable.
Therefore given that I already have a DataTable.... Why would I want to convert it to a DataReader?
Well I am creating an internal interface called IDataProvider. This interface is intended to be implemented both locally and as a WebService. The interface will have a method "Getdata" which takes some criteria information and returns some data.
Since a DataReader is the quickest data retrieval mechanism, I will want to use this as the result type of the "GetData" method. However we also know that the DataReader is not serializable and therefore cannot be transferred across the web via a web service...
In the case of the web I would have the local proxy class request the data as a DataTable and then transform it locally into a DataReader.
In this way the Local application need not know (or care) that if it is accessing the data locally or remotely.
However in order to do this I need to know... How do I wrap a DataReader around a preexisting DataTable?
Update: My business logic is not going to be held in the webservice since the DataProvider that uses the Webservice is switchable for one which does not. The businessLogic will therefore be held in the client app.
FWIW I am using .Net 3.5 SP1
Just call CreateDataReader()
on your DataTable