Beispiel #1
0
        public AllDocsResult All(ViewQuery query = null)
        {
            query = query ?? new ViewQuery();

            var path = "_all_docs";

            var responseContent = session.Get(path, query.ToDictionary());
            var final           = responseContent.DeserializeObject <AllDocsResult>();

            return(final);
        }
Beispiel #2
0
        public ViewResult <VALUE, DOC> View <VALUE, DOC>(string viewName, ViewQuery query = null, bool track = false) where DOC : new()
        {
            query = query ?? new ViewQuery();

            if (track && !query.IncludeDocs.HasValue)
            {
                query.IncludeDocs = true;
            }

            string path   = basePath + "/_view/" + viewName;
            var    config = Documents.GetConfiguration <DOC>();

            using (var client = new WebClient())
            {
                if (session.Credential != null)
                {
                    client.Credentials = session.Credential;
                }

                using (var stream = client.OpenRead(session.GetUri(path, query.ToDictionary())))
                {
                    using (var textReader = new StreamReader(stream, Encoding.UTF8))
                    {
                        using (var jsonReader = new JsonTextReader(textReader))
                        {
                            var serializer = new JsonSerializer();
                            serializer.NullValueHandling = NullValueHandling.Ignore;

                            if (typeof(DOC) != typeof(Object))
                            {
                                serializer.Converters.Add(new JsonCreationConverter <DOC>(config, track, Documents));
                            }

                            return(serializer.Deserialize <ViewDocsResultRaw <VALUE, DOC> >(jsonReader).ToViewResult());
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public ViewResult <VALUE, object> View <VALUE>(string viewName, ViewQuery query = null, bool track = false)
 {
     return(View <VALUE, object>(viewName, query));
 }
Beispiel #4
0
 public ViewResult <object, DOC> ViewDocs <DOC>(string viewName, ViewQuery query = null, bool track = false) where DOC : new()
 {
     query             = query ?? new ViewQuery();
     query.IncludeDocs = true;
     return(View <object, DOC>(viewName, query, track));
 }