zoukankan      html  css  js  c++  java
  • Linq 中的获取最大值得记录

    这是我写的第一个Linq 语句。写的比较慢。因为经常写sql现在写Linq 总是感觉不顺手。

    不说了,下面就是我的一个Linq语句。

    获得每组的记录数:

      var b = from a in List1
                        let pcount 
    = List2.Where(s => s.CenterId == a.CenterId).Count()
                        
    where a.CenterId!=0
                        select 
    new
                        {
                          groupID
    =1,
                          CenterID
    =a.CenterId,
                          lal 
    = a.Latitude,
                          lo 
    = a.Longitude,
                          isHave 
    = a.HasData,
                          countC 
    = pcount
                        };

     获取组中记录最大的

     var c = from d in b
                        group d by d.groupID into f
                        let e 
    = f.Max(d => d.countC)
                        from row 
    in f
                        
    where row.countC == e
                        select row;

    读取数据

     

     if (c.Count() > 0)
                {
                    double a = c.ToList()[0].lal;
                  }

    继续追寻。。。。。。
  • 相关阅读:
    AC3 encoder flow
    AC3 IMDCT
    AC3 Rematrix
    AC3 channel coupling
    AC3 mantissa quantization and decoding
    AC3 bit allocation
    AC3 exponent coding
    C# 判断字符串为数字 int float double
    vs 修改默认的调试浏览器
    visio 如何扩大画布大小
  • 原文地址:https://www.cnblogs.com/lfzwenzhu/p/2063188.html
Copyright © 2011-2022 走看看