是否有任何方法可以在datatview values上使用group by。我可以对dataview中的值进行排序,但如何在数据视图中对数据进行分组(在vb.net中)我想在数据视图上应用聚合函数如何使其成为可能?
You can group objects from a DataView
or any other data collection using the GroupBy method extension.
For a DataView you'd first have to cast it as IEnumerable(Of DataRowView)
. Here's a very simplistic example:
Dim groupedRows =
myDataView.Cast(Of DataRowView).GroupBy(Function(r) r("MyField"))
If you're using a typed DataSet
you might find it much easier to group on typed DataRow
instead as you'll be able to use hard properties for grouping rather than Object
values obtained with string references:
Dim groupedRows =
myDataTable.GroupBy(function(r) r.MyField)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.