Linq学习(6) Group & Join2010-07-12 博客园 飘遥(周振兴)本篇介绍Linq的Group和Join操作,继续使用《Linq 学习(3) 语法结构》中介绍的数据源。GroupGroup是进行分组操作,同SQL中的Group By类似。原型如下:public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>( this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)它有几个重载,返回类型有两种:IEnumerable<IGrouping<TKey, TSource>> 和 IEnumerable<TResult>。返回类型为:IEnumerable<IGrouping<TKey, TSource>>示例:返回按学号分组学生的成绩var result = from score in DataSource.Scores group score by score.StudentID into scoreGroup select scoreGroup;