I think I have the solution:
{
public class Class1
{
protected OdbcConnection Connection { get; set; }
protected OdbcCommand Command { get; set; }
protected OdbcDataReader Reader { get; set; }
public string BuildQuery1(string parm)
{
string query = string.Empty;
return query;
}
public string BuildQuery2(string parm1, double parm2)
{
string query = string.Empty;
return query;
}
public List<int> ProcessDataFromReader1()
{
return new List<int>();
}
public List<double> ProcessDataFromReader2()
{
return new List<double>();
}
public void GetGeneric()
{
Func<string> query = delegate { return this.BuildQuery1("parms"); };
Func<List<int>> read = delegate { return this.ProcessDataFromReader1(); };
GetData(query, read);
}
public void GetGeneric()
{
Func<string> query = delegate { return this.BuildQuery2("parms", 10d); };
Func <List<double>> read = delegate { return this.ProcessDataFromReader2(); };
GetData(query, read);
}
public void GetData<T>(Func<string> TQuery, Func<T> TRead)
{
Command.CommandText = TQuery();
using (Reader = Command.ExecuteReader())
{
while (Reader.Read())
{
TRead();
}
}
}
}
}