I am working on a panel. I started reorganizing the application, so the methods associated with querying the database are general or dynamic.
I am new to the concept of generics and still an amateur programmer, but I did a few searches and I tried to find a solution. The problem is not to build the query string dynamically. I'm fine with the concatenation of string literals and variables, I really don't need anything more complicated. The big problem for me is when I create this query, returning the data and assigning them to the right variables in a dynamic way.
Suppose I have a defect table, another for test cases and another for test runs. I want to create a method that looks something like this:
public void QueryDatabase<T>(ref List<T> Entitylist, List<string> Columns, string query) where T: Defect, new()
Now this is not perfect, but you get the idea. Not everything about defects, test scripts, and test runs is the same, but I'm looking for a way to dynamically assign recovered columns to my “correct” variable.
If you need more information, I can provide it.
source share