操作Datatable group by 查询 //获取统计图形数据 var dicleft = new Dictionary<string, DataTable>(); ].AsEnumerable() group t by new { mname = t.Field<string>("COL_MATERIAL_NAME") } into m select new { MaterialName = m.Key.mname, value = m.ToList…
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { internal class Program { private static void Main(string[] args) { DataTable dt = n…
对datatable 里面的数据按某一特定的栏位进行分组并且按照某一规则 var query = from t in rate.AsEnumerable() group t by new { t1 = t.Field<string>("Kind") } into m select new {Kind = m.Key.t1 }; if (query.ToList().Count > 0) { query.ToList().ForEach(q => { //根据…
本文转载自:http://www.cnblogs.com/sydeveloper/archive/2013/03/29/2988669.html 1.用两层循环计算,前提条件是数据已经按分组的列排好序的. DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("name", typeof(string)), new DataColumn("sex",…
DataTable分组统计: .用两层循环计算,前提条件是数据已经按分组的列排好序的. DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("name", typeof(string)), new DataColumn("sex", typeof(string)), new DataColumn("score", typeof(…