private Pageable <QueryResultPage> QueryInternal( QueryRequest queryRequest, string storeType, CancellationToken cancellationToken) { Page <QueryResultPage> FirstPageFunc(int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TimeSeriesInsightsClient)}.{nameof(QueryInternal)}"); scope.Start(); try { Response <QueryResultPage> response = _queryRestClient .Execute(queryRequest, storeType, null, null, cancellationToken); var frame = new QueryResultPage[] { response.Value }; return(Page.FromValues(frame, response.Value.ContinuationToken, response.GetRawResponse())); } catch (Exception ex) { scope.Failed(ex); throw; } } Page <QueryResultPage> NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TimeSeriesInsightsClient)}.{nameof(QueryInternal)}"); scope.Start(); try { Response <QueryResultPage> response = _queryRestClient .Execute(queryRequest, storeType, nextLink, null, cancellationToken); var frame = new QueryResultPage[] { response.Value }; return(Page.FromValues(frame, response.Value.ContinuationToken, response.GetRawResponse())); } catch (Exception ex) { scope.Failed(ex); throw; } } return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc)); }
/// <summary> /// Get all of the <see cref="TimeSeriesPoint"/> in pages synchronously. /// </summary> /// <returns>The pageable list <see cref="Pageable{TimeSeriesPoint}"/> of time series points.</returns> public Pageable <TimeSeriesPoint> GetResults() { Page <TimeSeriesPoint> FirstPageFunc(int?pageSizeHint) { try { Response <QueryResultPage> response = _queryClient .Execute(_queryRequest, _storeType, null, null, _cancellationToken); TimeSeriesPoint[] points = QueryHelper.CreateQueryResponse(response.Value); Progress = response.Value.Progress; return(Page.FromValues(points, response.Value.ContinuationToken, response.GetRawResponse())); } catch (Exception) { throw; } } Page <TimeSeriesPoint> NextPageFunc(string nextLink, int?pageSizeHint) { try { Response <QueryResultPage> response = _queryClient .Execute(_queryRequest, _storeType, nextLink, null, _cancellationToken); TimeSeriesPoint[] points = QueryHelper.CreateQueryResponse(response.Value); Progress = response.Value.Progress; return(Page.FromValues(points, response.Value.ContinuationToken, response.GetRawResponse())); } catch (Exception) { throw; } } return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc)); }