1.Datatable、DataRow[]、List 、List子集合、 某列求和
DataTable dt = new DataTable(); var sum1 = dt.Compute("SUM(Volume)", ""); DataRow[] drList = dt.Select("Name='AAA'"); var sum2 = drList.Sum(x => x.Field<decimal>("Volume")); var tJlbList = new List<TJlb_Mod>(); var sum3 = tJlbList.Sum(o => o.FBcfs); var sum4 = tJlbList.SelectMany(x => x.TJlb_P_Items).Sum(o => o.FBcfs);
2.List 多属性分组
var itemList = base.ConvertToModel<Biz_Sell_ProduceshippingAdjust_Mod>(dt); var query = itemList.GroupBy(pet => new { pet.ProduceshippingAdjustID, pet.ProduceTaskID, pet.ProduceTaskID1, pet.CancelNum, pet.DTime, pet.DTime1 });