当前位置:编程学习 > C#/ASP.NET >>

linq问题

            IEnumerable<DataRow> GroupRow = dt2.Rows.OfType<DataRow>();
            GroupRow.GroupBy(dr=>dr["item"]); 
我用上面的语句跟根据对datatable dt2表根据列名为Item的列进行分组,
出来的结果却没有有分组,不知道该怎么写
item        counts
aa            77
aa            99
bb             111
cc             333
dd             44
cc             444 --------------------编程问答-------------------- GroupRow.GroupBy(dr=>dr["item"]); 你还要赋值给其他的IEnumerable <DataRow>

参考 --------------------编程问答--------------------  你还要赋值给其他的IEnumerable <DataRow> 
没明白该怎么赋值给其他的IEnumerable 

表就上面的两列,我要分组求和。
能否帮写个完整的语句出来?
--------------------编程问答-------------------- 我这里没环境,不方便测,
根据我1楼的链接,你应该像 IEnumerable<IGrouping<int, int>> outerSequence = presidentsOptions.GroupBy(p => p.Id, p => p.Option,compare)一样,把选择的结果赋值到IEnumerable <DataRow> 里面,他本身的顺序可能没有变,你可以试试 --------------------编程问答-------------------- public static IEnumerable<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>( 
    this IEnumerable<TSource> source, 
    Func<TSource, TKey> keySelector)

var result = db.Student.GroupBy(Student=> Student.StudentID);
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,