It's all about the answers!

Ask a question

Help with IQueryResult and setting limits


1
1
Susan Hanson (1.6k2201194) | asked Dec 26 '13, 11:20 p.m.
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


Comments
sam detweiler commented 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().

One answer



permanent link
Susan Hanson (1.6k2201194) | answered Jan 07 '14, 6:26 a.m.
Perfect!  Thanks Sam

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.