• LinQ Coding (2)[标准查询运算符]


    标准查询运算符
     
    1.      在 LINQ 中,查询变量本身不执行任何操作并且不返回任何数据。
           它只是存储在以后某个时刻执行查询时为生成结果而必需的信息。
    2.      标准查询运算符”是组成语言集成查询 (LINQ) 模式的方法.
          共有两组 LINQ 标准查询运算符,一组在类型为 IEnumerable(T)的对象上运行,另一组在类型为 IQueryable(T)的对象上运行。
    * into 如果您必须引用组操作的结果,可以使用 into 关键字来创建可进一步查询的标识符。
     1  class StandSearchToLinq : Interface
     2     {
     3         #region Interface Members
     4 
     5         public void invoke()
     6         {
     7             string sentence = "the quick brown fox jumps over the lazy dog";
     8             string[] words = sentence.Split(' ');
     9 //标准查询
    10             var query = from word in words
    11                         group word.ToUpper() by word.Length into gr
    12                         orderby gr.Key
    13                         select new { Length = gr.Key, Words = gr };
    14 
    15 //Lambda
    16             var query2 = words.GroupBy(w => w.Length, w => w.ToUpper()).Select(g => new { Length = g.Key, Words = g }).OrderBy(o => o.Length);
    17 
    18             foreach (var obj in query2)
    19             {
    20                 Console.WriteLine("Words of Length {0}:", obj.Length);
    21                 foreach (string word in obj.Words)
    22                     Console.WriteLine(word);
    23             }
    24         }
    25 
    26         #endregion
    27     }
  • 相关阅读:
    Hadoop OutputFormat浅析
    硬盘性能
    HDFS读文件过程分析:读取文件的Block数据
    HDFS写文件过程分析
    JAVA中的编码分析
    HBase 写入优化
    HBase ttl 验证
    大数据多维分析平台的实践
    TiDB在特来电的探索
    Druid 基础使用-操作篇(Pivot、plyql)
  • 原文地址:https://www.cnblogs.com/qfb620/p/1116116.html
Copyright © 2020-2023  润新知