/// <summary>
 /// Temp function, will be removed when datamodel is consistent
 /// </summary>
 public async Task<IEnumerable<AllRatingsRow>> GetAllMovieRatings2()
 {
     using (var c = new MyCouchStore(_uri))
     {
         var query = new Query("views", "allRatings");
         query.Reduce = false;
         var result = await c.QueryAsync<AllRatingsRow>(query);
         return result.Select(x => x.Value);
     }
 }
 public IEnumerable<MovieRating> GetAllMovieRatings()
 {
     using (var c = new MyCouchStore(_uri))
     {
         var query = new Query("views", "allRatings");
         query.Reduce = false;
         var result = c.QueryAsync<MovieRating>(query).Result;
         return result.Select(x => x.Value);
     }
 }
 public async Task<IEnumerable<MovieInformationRow>> GetAllMovieInformation()
 {
     using (var c = new MyCouchStore(_uri))
     {
         var query = new Query("views", "movies");
         query.Group = true;
         var result = await c.QueryAsync<MovieInformationRow>(query);
         return result.Select(x => x.Value);
     }
 }
Beispiel #4
0
        public void ExportAllDataFromCouchToFiles()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["CouchDb"].ConnectionString;
            using (var c = new MyCouchStore(connectionString))
            {
                var query = new Query("_all_docs") {IncludeDocs = true};
                var result = c.QueryAsync(query).Result;

                var jsonFileParts = new List<string>();

                foreach (var obj in result)
                {
                    var doc = JsonConvert.DeserializeObject<JObject>(obj.IncludedDoc);

                    JToken type;
                    if (doc.TryGetValue("type", out type) && type.ToString() == "MovieRating")
                        jsonFileParts.Add(obj.IncludedDoc);
                }

                var json = "[\n" + String.Join(",\n", jsonFileParts) + "\n]";
                File.WriteAllText("TestData.json", json);
            }
        }