Help with IQueryResult and setting limits
I "inherited" some code and in reviewing it, I ended up with a question I was hoping someone could assist me with.
IQueryResult results = getQueryClient().getResolvedQueryResults(query, profile);
results.setLimit(queryLimit);
int total = validateWorkItemQueryResult(results);
while (results.hasNext(null)) {
//process the results
}
The results.setLimit(queryLimit); call is the part that is confusing. It looks like we have already run the query in the line above, so then would setLimit() do anything at that point? But if not, then how would I set the limit for the query before running the query itself?
Thanks,
Susan
IQueryResult results = getQueryClient().getResolvedQueryResults(query, profile);
results.setLimit(queryLimit);
int total = validateWorkItemQueryResult(results);
while (results.hasNext(null)) {
//process the results
}
The results.setLimit(queryLimit); call is the part that is confusing. It looks like we have already run the query in the line above, so then would setLimit() do anything at that point? But if not, then how would I set the limit for the query before running the query itself?
Thanks,
Susan
Comments
sam detweiler
Dec 27 '13, 8:04 a.m.Looking at the code, effectively there has been a Count done when the getResolvedQyeryResults() call is executed, but no results are actually fetched yet.
the setLimit() sets the fetch size. and the fetch is done on the first next().