首页 > 代码库 > DataTable 用linq分组查询

DataTable 用linq分组查询

 DataRow drt = null;            

var tlist = dt.Select("Atmbs LIKE ‘%" + d["Two_Code"] + "%‘").AsEnumerable().GroupBy(a => a.Field<string>("STATUS_MISSIONN")).Select(e => new { STATUS_MISSIONN = e.Key, Number = e.Count() });
                tlist.AsParallel().ForAll(item =>
                {
                    lock (_lock)
                    {
                        drt = dtCopy.NewRow();
                        drt["atmb"] = d["Short_Name"];
                        drt["STATUS_MISSIONN"] = item.STATUS_MISSIONN;
                        drt["STATUS_MISSIONNCOUNT"] = item.Number;
                        dtCopy.Rows.Add(drt);
                    }
                    
                });

 

 

 

private readonly static object _lock = new object();

DataTable 用linq分组查询