I have a function that selects some properties from an SQLite query. This function returns e.g. a static List<Requests>
. It works perfectly, the only problem is that I need this function to operate on many different objects, like cnn.Query<Requests>
, cnn.Query<Responses>
, and so on. So I dont want to call this function 20 times for 20 different objects.
Can someone show me please how I can make these <Requests>
or <Responses>
dynamic to just call the function one single time?
Two times nearly the same function that I want to reduce to one:
public static List<Requests> ReadRequests(SQLiteCommand command)
{
using (IDbConnection cnn = new SQLiteConnection(command.Connection))
{
var output = cnn.Query<Requests>("select * from Requests", new DynamicParameters());
return output.ToList();
}
}
public static List<Responses> ReadResponses(SQLiteCommand command)
{
using (IDbConnection cnn = new SQLiteConnection(command.Connection))
{
var output = cnn.Query<Responses>("select * from Requests", new DynamicParameters());
return output.ToList();
}
}