I created a class where the main task is get data from the DB and mapping it to some object. The problem is the same class needs to map different datareader to different object. So, what I tried to do is to get out the mapping method using delegates.
Here is part of my code. See the important rows in bold.
public class GetDetails<T>
public delegate void DelegateMapping(T position, IDataReader reader);
public DelegateMapping mappingMethod;
public T Get(T instance)
//Get IDs and Add to list
_db.ExecuteReader(storedProcedure.ToString(), CommandType.StoredProcedure, reader =>
while ( reader.Read() )
View Complete Post