I previously wrote
that the .NET 2.0 DataTableReader class
is really handy, but unfortunately there is no DataViewReader class. Thus, the only way to use the IDataReader interface with a sorted/filtered DataView was to first use the ToRows() method of the view to create a brand new DataTable, and then call CreateDataReader() on that new table. This is not the most efficient process when all you want to do is enumerate a DataView.
So, here's a solution: a simple, efficient, mostly-complete DataViewReader
class. Just create a new instance of it passing in the source DataView and off you go. This will be much more efficient than creating a brand new DataTable from the DataView, since we just use the default enumerator of the DataView and do not need to copy/create any more things in memory.
Most methods are implemented but a few aren't, feel free to complete the class if you need the missing functionality. It's pretty simple and straightforward.
If you find any bugs or have any suggestions for improvement, please let me know.
Click here for the code