I used to use the GetDbCount() function of the adapter to retrieve a "VirtualRecordCount" for a query in order to prepare the paging controls. It was pretty straight forward as I would just pass it the same IRelationPredicateBucket that I would pass FetchEntityCollection.
I can't quite work out how I would do that using QuerySpec.
Here is a sample of the old code (version 2.6):
// Entity collection that will hold the query result
var tickerItems = new EntityCollection<NewsTickerItemEntity>();
if (pagingOptions == null)
pagingOptions = new DataPagerOptions(0, false);
// Execute the query against the data store
Adapter.FetchEntityCollection(tickerItems, bucket, maxRecords, sortExpression, prefetchPath, includeExcludeFields,
pagingOptions.CurrentPage, pagingOptions.PageSize);
if (pagingOptions.SetVirtualCount)
{
var virtualCount = Adapter.GetDbCount(tickerItems, bucket);
PagingData = new DataPager(virtualCount, pagingOptions);
}
return tickerItems;