.ToListAsync<T>(Summary)
Async version of .ToList<T>(Summary). Uses EF Core's async count/materialization under the hood.
Signature
public static Task<SummaryResult> ToListAsync<T>(
this IQueryable<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.- Async count on the grouped query →
TotalCount. Orderapplied on the grouped query.Pageapplied on the grouped query.- Async materialization as
List<dynamic>.
Note
Dotted
GroupBy fields like Category.Name become flattened aliases in the result (e.g., CategoryName). Order fields in Summary.Orders use the dotted form — the library handles alias mapping internally.Returns
Task<SummaryResult>.
Example
SummaryResult result = await dbContext.Products.ToListAsync(summary);
foreach (var row in result.Data)
{
Console.WriteLine($"{row.CategoryName}: {row.ProductCount} products");
}ASP.NET Core endpoint.
app.MapPost("/products/summary", async (Summary summary, AppDbContext db) =>
{
var result = await db.Products.ToListAsync(summary);
return Results.Ok(result);
});{
"pageNumber": 1,
"pageSize": 10,
"pageCount": 1,
"totalCount": 3,
"data": [
{ "CategoryName": "Electronics", "ProductCount": 15, "AvgPrice": 349.99, "TotalRevenue": 5249.85 }
],
"queryString": null
}See also
.ToList<T>(Summary)— synchronous variant (and in-memory overload)..Summary<T>— non-materializing composition.- JSON Cookbook: Summary.