Convert rows from a data reader into typed results

后端 未结 10 2290
醉梦人生
醉梦人生 2020-11-27 11:53

I\'m using a third party library which returns a data reader. I would like a simple way and as generic as possible to convert it into a List of objects.
For example, say

10条回答
  •  生来不讨喜
    2020-11-27 12:25

    The simplest Solution :

    var dt=new DataTable();
    dt.Load(myDataReader);
    list dr=dt.AsEnumerable().ToList();
    

    Then select them in order to map them to any type.

提交回复
热议问题