How can I map a DataReader object into a class object by using generics?
For example I need to do the following:
public class Mapper
{
The easiest way I can think of offhand would be to supply a Func delegate for converting each column and constructing your book.
Alternatively, if you followed some conventions, you could potentially handle this via reflection. For example, if each column mapped to a property in the resulting object using the same name, and you restricted T in your Mapper to providing a constructable T, you could use reflection to set the value of each property to the value in the corresponding column.