首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

linq to sql分组查询解决办法

2013-12-06 
linq to sql分组查询linq to sql分组查询LINQ[解决办法] string[] words { blueberry, chimpanzee,

linq to sql分组查询
linq to sql分组查询linq to sql分组查询解决办法 LINQ
[解决办法]

 string[] words = { "blueberry", "chimpanzee", "abacus", "banana", "apple", "cheese" }; 
      
        var wordGroups = 
            from w in words 
            group w by w[0] into g 
            select new { FirstLetter = g.Key, Words = g }; 
      
        foreach (var g in wordGroups) 
        { 
            Console.WriteLine("Words that start with the letter '{0}':", g.FirstLetter); 
            foreach (var w in g.Words) 
            { 
                Console.WriteLine(w); 
            } 
        } 


http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

热点排行