public Task <IViewResult <T> > ViewQueryAsync <T>(string designDocument, string viewName, ViewOptions options = default)
        {
            if (options == default)
            {
                options = new ViewOptions();
            }

            // create old style query
            var query = new ViewQuery(GetViewUri().ToString())
            {
                UseSsl = _configuration.UseSsl
            };

            query.Bucket(Name);
            query.From(designDocument, viewName);
            query.Stale(options.StaleState);
            query.Limit(options.Limit);
            query.Skip(options.Skip);
            query.StartKey(options.StartKey);
            query.StartKeyDocId(options.StartKeyDocId);
            query.EndKey(options.EndKey);
            query.EndKeyDocId(options.EndKeyDocId);
            query.InclusiveEnd(options.InclusiveEnd);
            query.Group(options.Group);
            query.GroupLevel(options.GroupLevel);
            query.Key(options.Key);
            query.Keys(options.Keys);
            query.GroupLevel(options.GroupLevel);
            query.Reduce(options.Reduce);
            query.Development(options.Development);
            query.ConnectionTimeout(options.ConnectionTimeout);

            if (options.Descending.HasValue)
            {
                if (options.Descending.Value)
                {
                    query.Desc();
                }
                else
                {
                    query.Asc();
                }
            }

            if (options.FullSet.HasValue && options.FullSet.Value)
            {
                query.FullSet();
            }

            return(_viewClientLazy.Value.ExecuteAsync <T>(query));
        }
Exemple #2
0
 public override Task <IViewResult <T> > ViewQueryAsync <T>(string designDocument, string viewName, ViewOptions options = default)
 {
     throw new NotSupportedException("Views are not supported by Memcached Buckets.");
 }
        public override Task <IViewResult> ViewQueryAsync(string designDocument, string viewName, ViewOptions options)
        {
            // create old style query
            var query = new ViewQuery(GetViewUri().ToString())
            {
                UseSsl = Context.ClusterOptions.UseSsl
            };

            //Normalize to new naming convention for public API RFC#51
            var staleState = StaleState.None;

            if (options.ScanConsistency == ViewScanConsistency.RequestPlus)
            {
                staleState = StaleState.False;
            }
            if (options.ScanConsistency == ViewScanConsistency.UpdateAfter)
            {
                staleState = StaleState.UpdateAfter;
            }
            if (options.ScanConsistency == ViewScanConsistency.RequestPlus)
            {
                staleState = StaleState.Ok;
            }

            query.Bucket(Name);
            query.From(designDocument, viewName);
            query.Stale(staleState);
            query.Limit(options.Limit);
            query.Skip(options.Skip);
            query.StartKey(options.StartKey);
            query.StartKeyDocId(options.StartKeyDocId);
            query.EndKey(options.EndKey);
            query.EndKeyDocId(options.EndKeyDocId);
            query.InclusiveEnd(options.InclusiveEnd);
            query.Group(options.Group);
            query.GroupLevel(options.GroupLevel);
            query.Key(options.Key);
            query.Keys(options.Keys);
            query.Reduce(options.Reduce);
            query.Development(options.Development);
            query.ConnectionTimeout(options.ConnectionTimeout);
            query.Debug(options.Debug);
            query.Namespace(options.Namespace);
            query.OnError(options.OnError == ViewErrorMode.Stop);

            if (options.ViewOrdering == ViewOrdering.Decesending)
            {
                query.Desc();
            }
            else
            {
                query.Asc();
            }

            if (options.FullSet.HasValue && options.FullSet.Value)
            {
                query.FullSet();
            }

            foreach (var kvp in options.RawParameters)
            {
                query.Raw(kvp.Key, kvp.Value);
            }

            return(_viewClientLazy.Value.ExecuteAsync(query));
        }