예제 #1
0
                public async Task <bool> MoveNext(CancellationToken cancellationToken)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    if (_underlyingQuery == null)
                    {
                        _underlyingQuery = _cosmosClient.ExecuteAsyncSqlQuery(
                            _collectionId,
                            _selectExpression.ToSqlQuery(_queryContext.ParameterValues));
                    }

                    if (_underlyingEnumerator == null)
                    {
                        if (_underlyingQuery.HasMoreResults)
                        {
                            _underlyingEnumerator = (await _underlyingQuery.ExecuteNextAsync <Document>(cancellationToken))
                                                    .GetEnumerator();
                        }
                        else
                        {
                            Current = default;
                            return(false);
                        }
                    }

                    var hasNext = _underlyingEnumerator.MoveNext();

                    if (hasNext)
                    {
                        Current = _underlyingEnumerator.Current.GetPropertyValue <JObject>("query");
                        return(true);
                    }
                    else
                    {
                        _underlyingEnumerator.Dispose();
                        _underlyingEnumerator = null;
                        return(await MoveNext(cancellationToken));
                    }
                }