Esempio n. 1
0
        public virtual async Task <QueryInfo> GetValueByKeysAsync <TValue>(ViewIdentity view, object[] keys, Action <TValue> onResult, CancellationToken cancellationToken = default) where TValue : class
        {
            ThrowIfDisposed();

            EnsureArg.IsNotNull(view, nameof(view));
            EnsureArg.HasItems(keys, nameof(keys));
            EnsureArg.IsNotNull(onResult, nameof(onResult));

            var request  = new QueryViewRequest(view).Configure(r => r.Keys(keys));
            var response = await Client.Views.QueryAsync <TValue>(request, cancellationToken).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            foreach (var row in response.Rows.Where(r => r.Value != null))
            {
                onResult(row.Value);
            }

            return(CreateQueryInfoFrom(response, cancellationToken));
        }
Esempio n. 2
0
        public async virtual Task <QueryInfo> GetValueByKeysAsync <TValue>(ViewIdentity view, object[] keys, Action <TValue> onResult) where TValue : class
        {
            ThrowIfDisposed();

            Ensure.That(view, "view").IsNotNull();
            Ensure.That(keys, "keys").HasItems();
            Ensure.That(onResult, "onResult").IsNotNull();

            var request  = new QueryViewRequest(view).Configure(r => r.Keys(keys));
            var response = await Client.Views.QueryAsync <TValue>(request).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            foreach (var row in response.Rows.Where(r => r.Value != null))
            {
                onResult(row.Value);
            }

            return(CreateQueryInfoFrom(response));
        }
Esempio n. 3
0
        public virtual IObservable <TValue> GetValueByKeys <TValue>(ViewIdentity view, params object[] keys) where TValue : class
        {
            ThrowIfDisposed();

            Ensure.That(view, "view").IsNotNull();
            Ensure.That(keys, "keys").HasItems();

            return(Observable.Create <TValue>(async o =>
            {
                var request = new QueryViewRequest(view).Configure(r => r.Keys(keys));
                var response = await Client.Views.QueryAsync <TValue>(request).ForAwait();

                ThrowIfNotSuccessfulResponse(response);

                foreach (var row in response.Rows.Where(r => r.Value != null))
                {
                    o.OnNext(row.Value);
                }

                o.OnCompleted();

                return Disposable.Empty;
            }).SubscribeOn(ObservableSubscribeOnScheduler()));
        }
Esempio n. 4
0
        public virtual async Task <IEnumerable <TIncludedDoc> > GetIncludedDocByKeysAsync <TIncludedDoc>(ViewIdentity view, object[] keys, CancellationToken cancellationToken = default)
            where TIncludedDoc : class
        {
            ThrowIfDisposed();

            EnsureArg.IsNotNull(view, nameof(view));
            EnsureArg.HasItems(keys, nameof(keys));

            var request  = new QueryViewRequest(view).Configure(r => r.Keys(keys).IncludeDocs(true));
            var response = await Client.Views.QueryAsync <string, TIncludedDoc>(request, cancellationToken).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            return(response.Rows.Where(r => r.IncludedDoc != null).Select(r => r.IncludedDoc));
        }
Esempio n. 5
0
 public virtual Task <IEnumerable <string> > GetIncludedDocByKeysAsync(ViewIdentity view, object[] keys, CancellationToken cancellationToken = default)
 {
     return(GetIncludedDocByKeysAsync <string>(view, keys, cancellationToken));
 }
Esempio n. 6
0
        public virtual Task <QueryInfo> GetIncludedDocByKeysAsync(ViewIdentity view, object[] keys, Action <string> onResult, CancellationToken cancellationToken = default)
        {
            ThrowIfDisposed();

            return(GetIncludedDocByKeysAsync <string>(view, keys, onResult, cancellationToken));
        }
Esempio n. 7
0
        public Query(ViewIdentity viewIdentity)
        {
            EnsureArg.IsNotNull(viewIdentity, nameof(viewIdentity));

            State = new QueryParameters(viewIdentity);
        }
Esempio n. 8
0
        public virtual async Task <IEnumerable <TIncludedDoc> > GetIncludedDocByKeysAsync <TIncludedDoc>(ViewIdentity view, params object[] keys) where TIncludedDoc : class
        {
            ThrowIfDisposed();

            Ensure.That(view, "view").IsNotNull();
            Ensure.That(keys, "keys").HasItems();

            var request  = new QueryViewRequest(view).Configure(r => r.Keys(keys).IncludeDocs(true));
            var response = await Client.Views.QueryAsync <string, TIncludedDoc>(request).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            return(response.Rows.Where(r => r.IncludedDoc != null).Select(r => r.IncludedDoc));
        }
Esempio n. 9
0
 public virtual Task <IEnumerable <string> > GetIncludedDocByKeysAsync(ViewIdentity view, params object[] keys)
 {
     return(GetIncludedDocByKeysAsync <string>(view, keys));
 }
Esempio n. 10
0
        public virtual Task <QueryInfo> GetValueByKeysAsync(ViewIdentity view, object[] keys, Action <string> onResult)
        {
            ThrowIfDisposed();

            return(GetValueByKeysAsync <string>(view, keys, onResult));
        }
Esempio n. 11
0
        public Query(ViewIdentity viewIdentity)
        {
            Ensure.That(viewIdentity, "viewIdentity").IsNotNull();

            State = new QueryParameters(viewIdentity);
        }
Esempio n. 12
0
        public virtual async Task <QueryInfo> GetIncludedDocByKeysAsync <TIncludedDoc>(ViewIdentity view, object[] keys, Action <TIncludedDoc> onResult) where TIncludedDoc : class
        {
            ThrowIfDisposed();

            EnsureArg.IsNotNull(view, nameof(view));
            EnsureArg.HasItems(keys, nameof(keys));
            EnsureArg.IsNotNull(onResult, nameof(onResult));

            var request  = new QueryViewRequest(view).Configure(r => r.Keys(keys).IncludeDocs(true));
            var response = await Client.Views.QueryAsync <string, TIncludedDoc>(request).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            foreach (var row in response.Rows.Where(r => r.IncludedDoc != null))
            {
                onResult(row.IncludedDoc);
            }

            return(CreateQueryInfoFrom(response));
        }
Esempio n. 13
0
        public virtual async Task <IEnumerable <TValue> > GetValueByKeysAsync <TValue>(ViewIdentity view, params object[] keys) where TValue : class
        {
            ThrowIfDisposed();

            EnsureArg.IsNotNull(view, nameof(view));
            EnsureArg.HasItems(keys, nameof(keys));

            var request  = new QueryViewRequest(view).Configure(r => r.Keys(keys));
            var response = await Client.Views.QueryAsync <TValue>(request).ForAwait();

            ThrowIfNotSuccessfulResponse(response);

            return(response.Rows.Where(r => r.Value != null).Select(r => r.Value));
        }
Esempio n. 14
0
        public Query(ViewIdentity viewIdentity)
        {
            Ensure.That(viewIdentity, "viewIdentity").IsNotNull();

            State = new QueryParameters(viewIdentity);
        }
Esempio n. 15
0
 public virtual IObservable <string> GetIncludedDocByKeys(ViewIdentity view, params object[] keys)
 {
     return(GetIncludedDocByKeys <string>(view, keys));
 }