zoukankan      html  css  js  c++  java
  • LINQ 数据分组、统计实例

    接触LINQ不久,写的可能不规范,但我要的分组统计功能实现了

    贴出来供大家参考,如有高手还请指教,

    private List<OutBoundDetailExtend> _outBoundDetailExtendList;
    //赋值过程略
    …………
    var tmpList 
    = from L in _outBoundDetailExtendList
                              group L by 
    new { L.LocationId, L.PalletCode, L.SkuCode, L.Color, L.Size }
                                  into S
                                  select 
    new OutBoundDetailExtend
                                             {
                                                 AmountReceivable 
    =
                                                     S.Select(O 
    => O.AmountReceivable).First(),
                                                 BillId 
    = S.Select(O => O.BillId).First(),
                                                 Quantity 
    = S.Sum(O => O.Quantity),
                              …… 
    //实体赋值过程略                                           
                              SkuCode = S.Key.SkuCode,   
                                               UnitPrice = S.Select(O => O.UnitPrice).First()
                                             };
                _outBoundDetailExtendList 
    = tmpList.ToList();   
  • 相关阅读:
    leetcode211
    leetcode209
    leetcode201
    leetcode1396
    leetcode1395
    leetcode1394
    leetcode1386
    leetcode1387
    leetcode1382
    leetcode1376
  • 原文地址:https://www.cnblogs.com/pato/p/1970971.html
Copyright © 2011-2022 走看看