查询出来的表dtSumNaturalWorkHour,根据PersonName,ProjectName对WorkHour求和。
- var query = dtSumNaturalWorkHour.AsEnumerable().GroupBy(d => new { PersonName = d.Field<string>("PersonName"), ProjectName = d.Field<string>("ProjectName")
- })
- .Select(g => new
- {
- PersonName = g.Key.PersonName,
- ProjectName = g.Key.ProjectName,
- num = g.Sum(d => Convert.ToDouble(d["WorkHour"])),
- });
只根据一列值group 的查询求和:根据PersonName对WorkHour求和.
- var dt= dtSumNaturalWorkHour.Rows.Cast<DataRow>().GroupBy<DataRow, string>(row => Convert.ToString(row["PersonName"])).
- Select(group => new { group.Key, Value = group.Sum(x => Convert.ToDouble(x["WorkHour"])) });
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。