I currently have two methods:
CalculateDaily()
{
List<string> tempList;
// Effective query. not what is really passed
tempList = "SELECT timestamp FROM table1 WHERE date = today";
var total = tempList.Sum();
}
And:
CalculateTotal()
{
List<string> tempList;
// Effective query. not what is really passed
tempList = "SELECT timestamp FROM table1"
var total = tempList.Sum();
}
My question is should I keep them separate, or would it be feasible to combine them into a single method and run an if check? Something like:
Calculate(bool daily)
{
List<string> tempList;
if(daily)
tempList = "SELECT timestamp FROM table1 WHERE date = today";
else
tempList = "SELECT timestamp FROM table1";
var total = tempList.Sum();
}
I would use a method that provides a start- and an end-date. Then you can use it however you like.