Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Query'ing without any Take or Skip restriction only loads first page #60

@onepiecefreak3

Description

@onepiecefreak3

Using client.Query<T>() one will only receive the default 20 items from the first page. If we want to get more than that or all items of the given T, then we are bound to Skip and Take ourselves in a loop.
This approach however has one major flaw. Before the first execution of the query, you basically have no idea how many items you have in total, nor does the Query<T>() extension return the total value if Queryparameter withTotal=true.

A solution to that would be a client.QueryAll<T>() extension in addition to an appropriate enumerator for that case.
The enumerator will keep track of the current page items and retrieves new ones, if the page is exhausted.

Example:

var productQuery = client.QueryAll<Product>().Where(x => x.MasterData.Published);
foreach(var product in productQuery)
{
    ;  // Do things with the product
}

As you can see, the syntax would be nearly the same, while providing all items of a requested type on demand. So it will also not flood the machines memory with all the requested items at once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions