I don't see why you want to do it in one call. If you need to optimize the repository roundtrip for a separate total count call, I believe you are prematurely micro-optimizing unless you've measures that this particular call is your perf problem. And if you've measured it and it is, I reckon you have bigger problems with your repository.
I personally would stick with a simple Count
property on the same object that exposes GetItems
above.
Update: To address your question are there reasons not to design it as a single call:
It makes your API more complex and more ambiguous than it needs to be. GetItems()
main intention (as declared above) is to deal with a single page of items; adding the out
parameter for the total count of items overloads that semantic.
Here's something to consider - if I care only about the total count of items, will I have to call GetItems
or will there be a separate method? If there is a separate method, why are there two ways of accessing the same information and is it possible that they might return different results? And if there is no separate result, why should I have to get a full page of records just to get the total count of items in the repository?