예제 #1
0
        public virtual async Task <IEnumerable <Row <TValue, TIncludedDoc> > > QueryAsync <TValue, TIncludedDoc>(Query query, CancellationToken cancellationToken = default)
        {
            ThrowIfDisposed();

            EnsureArg.IsNotNull(query, nameof(query));

            var response = await Client.Views.QueryAsync <TValue, TIncludedDoc>(query.ToRequest(), cancellationToken).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            return(response.Rows.Select(r => new Row <TValue, TIncludedDoc>(r.Id, r.Key, r.Value, r.IncludedDoc)));
        }
예제 #2
0
        public virtual async Task <IEnumerable <Row <TValue, TIncludedDoc> > > QueryAsync <TValue, TIncludedDoc>(Query query)
        {
            ThrowIfDisposed();

            Ensure.That(query, "query").IsNotNull();

            var response = await Client.Views.QueryAsync <TValue, TIncludedDoc>(query.ToRequest()).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            return(response.Rows.Select(r => new Row <TValue, TIncludedDoc>(r.Id, r.Key, r.Value, r.IncludedDoc)));
        }
예제 #3
0
        public virtual async Task <QueryInfo> QueryAsync <TValue, TIncludedDoc>(Query query, Action <Row <TValue, TIncludedDoc> > onResult, CancellationToken cancellationToken = default)
        {
            ThrowIfDisposed();

            EnsureArg.IsNotNull(query, nameof(query));

            var response = await Client.Views.QueryAsync <TValue, TIncludedDoc>(query.ToRequest(), cancellationToken).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            foreach (var row in response.Rows)
            {
                onResult(new Row <TValue, TIncludedDoc>(row.Id, row.Key, row.Value, row.IncludedDoc));
            }

            return(CreateQueryInfoFrom(response, cancellationToken));
        }
예제 #4
0
        public virtual async Task <QueryInfo> QueryAsync <TValue, TIncludedDoc>(Query query, Action <Row <TValue, TIncludedDoc> > onResult)
        {
            ThrowIfDisposed();

            Ensure.That(query, "query").IsNotNull();

            var response = await Client.Views.QueryAsync <TValue, TIncludedDoc>(query.ToRequest()).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            foreach (var row in response.Rows)
            {
                onResult(new Row <TValue, TIncludedDoc>(row.Id, row.Key, row.Value, row.IncludedDoc));
            }

            return(CreateQueryInfoFrom(response));
        }
예제 #5
0
        public virtual IObservable <Row <TValue, TIncludedDoc> > Query <TValue, TIncludedDoc>(Query query)
        {
            ThrowIfDisposed();

            Ensure.That(query, "query").IsNotNull();

            return(Observable.Create <Row <TValue, TIncludedDoc> >(async o =>
            {
                var response = await Client.Views.QueryAsync <TValue, TIncludedDoc>(query.ToRequest()).ForAwait();

                ThrowIfNotSuccessfulResponse(response);

                foreach (var row in response.Rows)
                {
                    o.OnNext(new Row <TValue, TIncludedDoc>(row.Id, row.Key, row.Value, row.IncludedDoc));
                }

                o.OnCompleted();

                return Disposable.Empty;
            }).SubscribeOn(ObservableSubscribeOnScheduler()));
        }