我目前有两种方法:
CalculateDaily()
{
List<string> tempList;
// Effective query. not what is really passed
tempList = "SELECT timestamp FROM table1 WHERE date = today";
var total = tempList.Sum();
}
和:
CalculateTotal()
{
List<string> tempList;
// Effective query. not what is really passed
tempList = "SELECT timestamp FROM table1"
var total = tempList.Sum();
}
我的问题是我应该将它们分开,还是将它们组合成一个方法并运行if
检查是否可行?就像是:
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();
}