This sample implements the LINQ Group-by feature with the Essential Grouping grid control.
LINQ Group-by
Now the grouping engine supports IEnumerable as a data source and a nested collection. Before, there always had to be an IList.
The grouping-engine data source can also be a Syncfusion.Grouping.IPassThroughGroupingResult, with the default implementation of this interface being the Syncfusion.Grouping.PassThroughGroupingResult class. The PassThroughGroupingResult class can be used for LINQ queries.
There is also support for getting summaries from a LINQ query. All you have to do is set the SummaryType to be SummaryType.Custom in the GridSummaryColumnDescriptor and the engine will retrieve summaries from matching property names in the Group.PassThroughItem object, which can be a LINQ group with summaries.
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;