How do I convert a DataTable to an IDatareader?

后端 未结 4 1426
南旧
南旧 2021-02-07 19:03

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 DataTab

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-07 19:54

    There is no existing class that will do this for you. But it shouldn't be hard for you to write a serializable class that implements IDataReader and is a wrapper round your existing DataTable.

    EDIT: You might find it easier to inherit from DbDataReader (I think, check the base class of SqlDataReader in object explorer). It provides some of the interface implentation for you. But yes, it is still quite a lot of dull code.

提交回复
热议问题