1.按照第一个字母进行分组

     static void Main(){string[] words = { "blueberry", "chimpanzee", "abacus", "banana", "apple", "cheese" };var wordGroupByFirstLetter =from word in wordsgroup word by word[0] into worderby w.Keyselect w;foreach (var groupedWord in wordGroupByFirstLetter){Console.WriteLine("word that start with letter is {0}",groupedWord.Key);foreach (var word in groupedWord){Console.WriteLine("{0}", word);}}}

2.按照平均分大于80的

public class Student{public string First { get; set; }public string Last { get; set; }public int ID { get; set; }public List<int> Scores;}class Program{public static List<Student> GetStudents(){List<Student> students = new List<Student>{new Student {First="Svetlana", Last="Omelchenko", ID=111, Scores= new List<int> {97, 72, 81, 60}},new Student {First="Claire", Last="O'Donnell", ID=112, Scores= new List<int> {75, 84, 91, 39}},new Student {First="Sven", Last="Mortensen", ID=113, Scores= new List<int> {99, 89, 91, 95}},new Student {First="Cesar", Last="Garcia", ID=114, Scores= new List<int> {72, 81, 65, 84}},new Student {First="Debra", Last="Garcia", ID=115, Scores= new List<int> {97, 89, 85, 82}} };return students;}static void Main(string[] args){List<Student> students = GetStudents();var boolenGroupQuery =from student in studentsgroup student by student.Scores.Average() > 80;foreach (var boolAverage in boolenGroupQuery){Console.WriteLine("{0}", boolAverage.Key == true ? "High Average" : "Low Average");foreach (var student in boolAverage){Console.WriteLine("First:{0},last:{1},Average:{2}", student.First, student.Last, student.Scores.Average());}}}

LINQ Group Query相关推荐

  1. Linq Group By 注意点

    比如有如下的Linq查询: var q = from s in agedDebtCollection group s by s.SalesPersonCode into p select new { ...

  2. Advanced Linq - Dynamic Linq query library: Add support for 'Contains' extension

    原文链接: http://blog.walteralmeida.com/2010/05/advanced-linq-dynamic-linq-library-add-support-for-conta ...

  3. c# 第六课 linq

    LINQ (Language-INtegrated Query) Programmers perform every day is finding and retrieving (存取) object ...

  4. 再试译ScottGu's Posts 之 VS2008之语言特性--查询语法--New Orcas Language Feature: Query Syntax...

    学习一门新的语言,总要从其语法学起.为了方便大家学习,同时也为了自己学习,就将ScottGu的这篇关于3.5中增加的新的特性帖子译了出来.这次我翻译采用中汉对照的方式,不然像上次译的那个那样的话不但我 ...

  5. .NET中那些所谓的新语法之四:标准查询运算符与LINQ

    开篇:在上一篇中,我们了解了预定义委托与Lambda表达式等所谓的新语法,这一篇我们继续征程,看看标准查询运算符和LINQ.标准查询运算符是定义在System.Linq.Enumerable类中的50 ...

  6. ScottGu之博客翻译-LINQ to SQL第三部分,查询数据库 (Part 3 - Querying our Database)

     本贴只为共享知识,更为简洁(即无英文的版本)将会发布在博客堂上,堂主正对此文进行审阅. 希望本贴能对您的LINQ to SQL语言的学习有一定的帮助! 原贴链接: http://weblogs.as ...

  7. Solr分组聚合查询之Group

    摘要: Solr对结果的分组处理除了facet还可以使用group.Solr的group是根据某一字段对结果分组,将每一组内满足查询的结果按顺序返回. Group对比Facet Group和Facet ...

  8. 使用Dynamic LINQ实现Ext Grid的远程排序

    要实现Ext Grid的远程排序其实很简单,只要修改查询语句的排序关键字就可以了,但是,如果你的项目是使用Linq进行开发的,会发现动态修改排序关键字并不是那么容易的事,解决办法就是使用LINQ Dy ...

  9. 电子书下载:Programming Microsoft LINQ in Microsoft .NET Framework 4

    Book Description Dig into LINQ - and transform the way you work with data. With LINQ, you can query ...

最新文章

  1. jdbc封装与多并发的共鸣
  2. mht to html
  3. 并查集数据结构的几种实现
  4. SpringMvc通过@Value( ) 给静态变量注入值
  5. 【深度学习】基于web端和C++的两种深度学习模型部署方式
  6. 【若依(ruoyi)】Bootstrap-Table的使用
  7. Bean实例化三种方式
  8. 前端学习(1840):前端面试题之小程序入门
  9. Python heapq模块
  10. nodejs实践录:我的nodejs编码风格
  11. 超详细 | 接口自动化测试总结与分享入门篇
  12. 如何使用cURL一次测量请求和响应时间?
  13. C#反射获取 所有字段 及 私有字段
  14. [渝粤教育] 淄博职业学院 市场营销 参考 资料
  15. 坐标转换工具类:84坐标系,火星坐标系,与百度坐标系之间的互相转换
  16. Zemax自学--2(Zemax软件总览)
  17. Python量化投资——年化收益26%,一个大小盘轮轮动量化投资策略的回测效果
  18. BDB 入门篇 第6章 A DPL Example一个DPL 例子
  19. 143_win10如何删除默认输入法
  20. Microsoft Teams管理(一)

热门文章

  1. WebSocket connection to ‘ws://XXX‘ failed: Error during WebSocket handshake报错
  2. python电子英汉词典显示_如何使用python为Linux打造一款命令行下的在线英汉词典...
  3. 深度相机 物体三维重建_基于深度相机的实时物体三维重建方法与流程
  4. 2020HW漏洞总结(三)
  5. 开源web框架_带有酷名称的开源JavaScript和Web框架的词汇表
  6. ubuntu使用exiftool查看图片exif信息
  7. pentaho-server 与 Pentaho Data Integration(pentaho-kettle)
  8. Altium Designer 18PCBLogo制作
  9. C++的一个指针占内存几个字节?
  10. 计算机基础应用在线免费答题,计算机应用基础简答题附答案.doc