zoukankan      html  css  js  c++  java
  • 对DataTable的DataRow做group

       1:  public void DataSetLinq41()
       2:  {
       3:      var words4 = testDS.Tables["Words4"].AsEnumerable();
       5:      var wordGroups =
       6:          from w in words4
       7:          group w by w.Field<string>("word")[0] into g
       8:          select new { FirstLetter = g.Key, Words = g };
      10:      foreach (var g in wordGroups)
      11:      {
      12:          Console.WriteLine("Words that start with the letter '{0}':", g.FirstLetter);
      13:          foreach (var w in g.Words)
      14:          {
      15:              Console.WriteLine(w.Field<string>("word"));
      16:          }
      17:      }
      18:      Console.ReadLine();
      19:  }
      20:   
      21:   
      22:  private static DataTable CreateWords4Table()
      23:  {
      24:      string[] words = { "blueberry", "chimpanzee", "abacus", "banana", "apple", "cheese" };
      25:      DataTable table = new DataTable("Words4");
      26:      table.Columns.Add("word", typeof(string));
      27:   
      28:      foreach (string word in words)
      29:      {
      30:          table.Rows.Add(new object[] { word });
      31:      }
      32:      return table;
      33:  }
      34:   
      35:  DataSetLinq41();
  • 相关阅读:
    JS常用设计模式
    react native两次点击返回按钮退出APP
    react-native-device-info集成遇到的坑
    Django环境搭建之hello world
    jmeter之beanshell断言实例
    jmeter之beanshell断言---数据处理
    Jmeter将JDBC Request查询结果作为下一个接口参数方法(转载)
    App功能测试的注意点
    mybatis的CRUD实例(四)
    mybatis的CRUD实例(三)
  • 原文地址:https://www.cnblogs.com/pnljs/p/2933672.html
Copyright © 2011-2022 走看看