.ToList<T>(Summary)
Materializes a Summary and returns a SummaryResult with pagination metadata.
Guarded, small groups are dropped by default
DwCaps.MinGroupSize ships on, at 5, so a guarded summary removes every group with fewer than five rows — not refused, and nothing in the answer says a group was dropped. That is right for anonymised reporting and surprising for an operational count. Set Caps.MinGroupSize = 1 to switch the floor off, deliberately. An unguarded call is never floored. See k-anonymity.IQueryable<T> overload
public static SummaryResult ToList<T>(
this IQueryable<T> query,
Summary summary,
bool getQueryString = false)
where T : classIEnumerable<T> overload
In-memory variant for summary operations.
public static SummaryResult ToList<T>(
this IEnumerable<T> query,
Summary summary,
bool getQueryString = false)
where T : class| Parameter | Type | Default | Description |
|---|---|---|---|
summary | Summary | – | Composition object |
getQueryString | bool | false | When true, captures the generated SQL on SummaryResult.QueryString |
Pipeline
Whereapplied on the typed query.Groupapplied — produces grouped dynamic intermediate.Havingapplied — fields must reference aggregate aliases.Counton the grouped query →TotalCount.Orderapplied on the grouped query.Pageapplied on the grouped query.- Materialized as
List<dynamic>.
Note
Passing
getQueryString: true calls .ToQueryString(), which requires an active EF Core provider. On an in-memory source it does not fail — it returns a placeholder sentence where the SQL would be.Returns
SummaryResult with PageNumber, PageSize, PageCount, TotalCount, Data (List<dynamic> with group keys + aggregation values), and optional QueryString.
Example
SummaryResult result = dbContext.Products.ToList(summary);
foreach (var row in result.Data)
{
Console.WriteLine($"{row.CategoryName}: {row.ProductCount} products, avg {row.AvgPrice}");
}In-memory variant.
List<Product> source = LoadFromCsv();
SummaryResult result = source.ToList(summary);{
"pageNumber": 1,
"pageSize": 10,
"pageCount": 1,
"totalCount": 3,
"data": [
{ "CategoryName": "Electronics", "ProductCount": 15, "AvgPrice": 349.99, "TotalRevenue": 5249.85 },
{ "CategoryName": "Clothing", "ProductCount": 12, "AvgPrice": 45.00, "TotalRevenue": 540.00 }
],
"queryString": null
}Warning
Dotted
GroupBy fields like Category.Name become flattened aliases in the result (e.g., CategoryName).See also
.ToListAsync<T>(Summary)— async EF Core variant..Summary<T>— non-materializing composition.SummaryResultshape.