Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
onepiecefreak3 opened this issue Sep 19, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@onepiecefreak3
Copy link
Contributor

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.

@jenschude
Copy link
Contributor

Still thinking about this. The problem here is that this would only work as long as no other sort criteria has been added to the command. So please be patient before we take a closer look to your PR.

@jenschude jenschude added the enhancement New feature or request label Oct 10, 2019
@onepiecefreak3
Copy link
Contributor Author

The command itself still has all the functionality intact. The only thing it does is adding an enumerator that actually yields all results instead of just the first default page. All criteria should apply on the API. Maybe I miss something and you can elaborate?

@onepiecefreak3
Copy link
Contributor Author

onepiecefreak3 commented Jan 16, 2023

I'm not sure how this works, but bumping this after 3 and a half years.
I no longer need this functionality, which is why I didn't bother keeping track of it.
But what I last wrote still stands, I assume. All criteria still apply. I just wrapped the code to yield all results, instead of just the default page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants