如何在Datarow []中进行Datarow [] Groupby和orderby结果集

时间:2013-12-05 02:16:34

标签: c#

我想在.NET 3.5中做这样的事情。什么是最快捷的方式?

IEnumerable<DataRow[]> list =
                (from r in datarow.AsEnumerable()
                 group r by r[CoumnName]).
                 SelectMany(g => g.OrderBy(r => r[CoumnName]));

Datarow[]  resultDatarow = list.Cast<Datarow[]>;

怎么做?

1 个答案:

答案 0 :(得分:2)

也许您可以使用ToArray而不使用SelectMany

IEnumerable<DataRow[]> list = (from r in datarow.AsEnumerable()
                               group r by r[CoumnName]).
                               Select(g => g.OrderBy(r => r[CoumnName]).ToArray());
Datarow[][]  resultDatarow = list.ToArray();