O'Reilly logo

Visual Basic 2008 Recipes: A Problem-Solution Approach by Rakesh Rajan, Matthew MacDonald, Allen Jones, Todd Herman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.10. Group Query Results

Problem

You need to query data that is stored in a collection or array, but you need group the data in some hierarchical format.

Solution

Create a standard LINQ query, such as the ones described in the previous recipes, and use the Group By clause to specify how the data should be organized.

How It Works

The Group By clause is used to organize the data returned from a query in a hierarchical format, meaning that data is returned as groups of elements or even groups of grouped elements. The format for the first portion of the clause is Group fields By key fields, where fields is a list of fields that will be included with the grouped data and key fields represents how the data is actually grouped. If no fields are supplied, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required