Question

I would like to implement a "Group By" for my datatable. Has any one any suggestions?

update:

c#, .net 2.0

Was it helpful?

Solution

You can use the linq extensions in the System.Data.DataSetExtensions assembly:

DataTable t = //
var groups = t.AsEnumerable()
    .GroupBy(r => r.Field<T>("columnName"))

OTHER TIPS

Use LINQ to DataSets and the GroupBy extension methods.

Add assembly System.Data.DataSetExtensions.dll to your project to get access to the AsEnumerable() extension method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top