Answer the question
In order to leave comments, you need to log in
How to pass the request I need to the method?
The situation is simple. There is a GetData method. It gets all the data from the db and returns it.
public List<UserData> GetData(int FL)
{
string sql = string.Format(@"SELECT id, guid, username, userblob, ""FL"" FROM ""USERS"" WHERE ""FL""={0};", FL);
...
UserData ud = new UserData();
ud.Id = dr[0].ToString();
ud.Guid = (dr[1].ToString());
ud.Name = (dr[2].ToString());
ud.UserBlob = (byte[])dr[3];
ud.FL = dr[4].ToString();
uds.Add(ud);
...
return uds;
}
TargetDbContext = DbContextFactory.GetDbContext(_config.FirstDataBase);
TransitDbContext = DbContextFactory.GetDbContext(_config.TransitDataBase);
Answer the question
In order to leave comments, you need to log in
public List<UserData> GetData(int FL, string query)
{
switch (query)
{
case "WHERE":
// Делаем запрос WHERE
break;
case "SELECT":
// Делаем запрос SELECT
break;
}
return uds;
}
However, I have a need...
Sounds like the task of passing optional filters (optional parameters to a C# method).
But it is also possible to pass in general an external function as a parameter , which will be pulled by GetData for calculations unknown to it. Although, for me, the situation is more likely to signal an incorrectly designed code ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question