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); }
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()); } } } } }