コード例 #1
0
 /// <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);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
ファイル: Tools.cs プロジェクト: HeavyHenke/KarinsFilmer
        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);
            }
        }