.ToListAsyncDynamic<T>(Filter)
Async version of .ToListDynamic<T>(Filter). Uses EF Core's CountAsync() and ToDynamicListAsync() under the hood.
Signature
public static Task<FilterResult<dynamic>> ToListAsyncDynamic<T>(
this IQueryable<T> query,
Filter filter,
bool getQueryString = false)
where T : class| Parameter | Type | Default | Description |
|---|---|---|---|
filter | Filter | – | Composition object |
getQueryString | bool | false | When true, captures the generated SQL on QueryString |
Pipeline
Whereapplied on the typed query.CountAsync()on the typed query →TotalCount.Orderapplied on the typed query.Pageapplied on the typed query.SelectDynamicprojection applied last.ToDynamicListAsync()materializes the result.
Warning
Ordering and pagination are applied on the strongly-typed
IQueryable<T> before the dynamic projection so that field names referenced in orders always resolve against the original entity type T.Note
Property names in the dynamic result follow
SelectDynamic rules — see that page for the full set of access patterns through nested dynamic objects and collections.Returns
Task<FilterResult<dynamic>>.
Example
FilterResult<dynamic> result = await dbContext.Products.ToListAsyncDynamic(filter);
foreach (var p in result.Data)
{
Console.WriteLine($"{p.Name} — {p.Category.Name}");
}var result = await dbContext.Products.ToListAsyncDynamic(filter, getQueryString: true);
Console.WriteLine(result.QueryString);{
"pageNumber": 1,
"pageSize": 10,
"pageCount": 5,
"totalCount": 42,
"data": [
{ "Id": 7, "Name": "Laptop Pro", "Price": 1299.99, "Category": { "Name": "Electronics" } }
],
"queryString": null
}See also
.ToListDynamic<T>(Filter)— synchronous variant (and in-memory overload)..ToListAsync<T>(Filter)— async typed variant..FilterDynamic<T>— non-materializing composition.