Aggregating data

Docs

The GroupBy property groups the returned data by all the columns that do not have an Aggregate property set. In this example the data is grouped by Product.

Razor
                                
                                        
DbNetGridCore productSalesSummaryGrid = new DbNetGridCore("northwind", "Invoices");
productSalesSummaryGrid.Columns = new List() { "ProductName", "OrderDate as FirstOrder", "OrderDate as LastOrder", "(UnitPrice * Quantity) as TotalValue", "(UnitPrice * Quantity) as AvgValue" };
productSalesSummaryGrid.Labels = new List() {  "Product", "First Order", "Last Order", "Total Value", "Average Value" };
productSalesSummaryGrid.GroupBy = true;
productSalesSummaryGrid.Column(new String[] { "TotalValue", "AvgValue" }).Format("c");
productSalesSummaryGrid.Column(new String[] { "FirstOrder", "LastOrder" }).Format("MMM yyyy");
productSalesSummaryGrid.Column(new String[] { "TotalValue", "AvgValue" }).DataType(typeof(Decimal));
productSalesSummaryGrid.Column("FirstOrder").Aggregate(AggregateType.Min);
productSalesSummaryGrid.Column("LastOrder").Aggregate(AggregateType.Max);
productSalesSummaryGrid.Column("TotalValue").Aggregate(AggregateType.Sum);
productSalesSummaryGrid.Column("AvgValue").Aggregate(AggregateType.Avg);
@productSalesSummaryGrid.Render()