C# – Convert datatable to datareader


For Performance improvement I want to convert datatable to datareader. I can not do that through query. So is there any other way to do so?

Best Solution

I know this is old, but the answers here seem to have missed the point of the OPs question.

DataTables have a method called CreateDataReader which will allow you to convert a DataTable to a DbDataReader object. In this case a DataTableReader.

DataTable table = new DataTable(); 
//Fill table with data 
//table = YourGetDataMethod(); 
DataTableReader reader = table.CreateDataReader();

I should point out that this will not increase performance since you should be using one or the other.

Here are some more resources on the matter: