Get an IDataReader from a typed List

You can use Marc Gravell’s FastMember:

IDataReader reader = ObjectReader.Create(myEnumerable); //all columns
IDataReader reader = ObjectReader.Create(myEnumerable, "Id", "Name", "Description");

In addition to abstracting away the creation logic, it also uses IL to get the property/field values, which is faster than reflection.

Leave a Comment

tech