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

Add paging to queries #8

Closed
Arithmomaniac opened this issue Nov 8, 2017 · 2 comments
Closed

Add paging to queries #8

Arithmomaniac opened this issue Nov 8, 2017 · 2 comments
Assignees

Comments

@Arithmomaniac
Copy link
Collaborator

Currently, RsapiDao.GetRDOs(Condition) returns a List<T> and pulls all items down at once.

In order to enable handling of large sets, it would be better to use an IEnumerable<T> for queries, and pull results by paging. The general idea can be seen in the following code snippet we have used before at Milyli:

var initialResultSet = repo.Query(query, pageLength);

foreach (var result in initialResultSet.Results)
    yield return result;

string queryToken = initialResultSet.QueryToken;

// Iterate though all remaining pages
var totalCount = initialResultSet.TotalCount;
int currentPosition = pageLength + 1;

while (currentPosition <= totalCount)
{
    var subsetResult = repo.QuerySubset(queryToken, currentPosition, pageLength);
    foreach (var result in subsetResult.Results)
        yield return result;

    currentPosition += pageLength;
}

The paging could be set as a global configuration and/or on the specific call, and fallback to "no paging" if not set.

@Arithmomaniac
Copy link
Collaborator Author

I've started work on this: Arithmomaniac/Gravity/feature/Paging_8

@ggachevski
Copy link
Contributor

Very clean, very useful -- necessary, I should say.

Since I am on the direct-SQL calls wave right now (under #24), this Paging will be well handled by SQL server too, so same method signatures will remain and you will be able to do this as easily (and much more quickly) via a SQL-based implementation, soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants