📅  最后修改于: 2022-03-11 14:58:58.687000             🧑  作者: Mango
private void GetValuesGroupedBy(List> list, List groupbyNames, List summableNames)
{
// build the groupby string
StringBuilder groupBySB = new StringBuilder();
groupBySB.Append("new ( ");
bool useComma = false;
foreach (var name in groupbyNames)
{
if (useComma)
groupBySB.Append(", ");
else
useComma = true;
groupBySB.Append("it[\"");
groupBySB.Append(name);
groupBySB.Append("\"]");
groupBySB.Append(" as ");
groupBySB.Append(name);
}
groupBySB.Append(" )");
var groupby = list.GroupBy(groupBySB.ToString(), "it");
}