LINQ Group-by Demo

This sample implements the LINQ Group-by feature with the Essential Grouping grid control.

 LINQ Group-by

 

Word 2007 Image

 

Features

Implementation

            PassThroughGroupingResult productQueryResults = new PassThroughGroupingResult(
                    "Product",
                    productQuery,
                    typeof(Product),
                    productTotals,
                    productSampleQuery.Take(10),
                    "Supplier"
                    );

            grid.DataSource = productQueryResults;

If the data source is a pass-through-grouping result, then Group.PassThroughItem will be set by the engine, and it will contain the aggregates for the LINQ groups. For other data sources, you can set this manually.

 The engine can create new items when the list-item type is specified for the pass-through-grouping resultant CTOR where the list-item type needs to have a default CTOR with no arguments.

With UniformChildListRelation, a new UseLazyUniformChildListRelation property has been added to speed up load time of the grid and reduce memory usage when all records are not expanded. This should work with any regular nested-collection setup.

            grid.UseLazyUniformChildListRelation = true;