public void InsertTestData() { using (var redisUsers = redisClient.GetTypedClient<User>()) using (var redisBlogs = redisClient.GetTypedClient<Blog>()) using (var redisBlogPosts = redisClient.GetTypedClient<BlogPost>()) { var ayende = new User { Id = redisUsers.GetNextSequence(), Name = "Oren Eini" }; var mythz = new User { Id = redisUsers.GetNextSequence(), Name = "Demis Bellot" }; var ayendeBlog = new Blog { Id = redisBlogs.GetNextSequence(), UserId = ayende.Id, UserName = ayende.Name, Tags = new List<string> { "Architecture", ".NET", "Databases" }, }; var mythzBlog = new Blog { Id = redisBlogs.GetNextSequence(), UserId = mythz.Id, UserName = mythz.Name, Tags = new List<string> { "Architecture", ".NET", "Databases" }, }; var blogPosts = new List<BlogPost> { new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = ayendeBlog.Id, Title = "RavenDB", Categories = new List<string> { "NoSQL", "DocumentDB" }, Tags = new List<string> {"Raven", "NoSQL", "JSON", ".NET"} , Comments = new List<BlogPostComment> { new BlogPostComment { Content = "First Comment!", CreatedDate = DateTime.UtcNow,}, new BlogPostComment { Content = "Second Comment!", CreatedDate = DateTime.UtcNow,}, } }, new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = mythzBlog.Id, Title = "Redis", Categories = new List<string> { "NoSQL", "Cache" }, Tags = new List<string> {"Redis", "NoSQL", "Scalability", "Performance"}, Comments = new List<BlogPostComment> { new BlogPostComment { Content = "First Comment!", CreatedDate = DateTime.UtcNow,} } }, new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = ayendeBlog.Id, Title = "Cassandra", Categories = new List<string> { "NoSQL", "Cluster" }, Tags = new List<string> {"Cassandra", "NoSQL", "Scalability", "Hashing"}, Comments = new List<BlogPostComment> { new BlogPostComment { Content = "First Comment!", CreatedDate = DateTime.UtcNow,} } }, new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = mythzBlog.Id, Title = "Couch Db", Categories = new List<string> { "NoSQL", "DocumentDB" }, Tags = new List<string> {"CouchDb", "NoSQL", "JSON"}, Comments = new List<BlogPostComment> { new BlogPostComment {Content = "First Comment!", CreatedDate = DateTime.UtcNow,} } }, }; ayende.BlogIds.Add(ayendeBlog.Id); ayendeBlog.BlogPostIds.AddRange(blogPosts.Where(x => x.BlogId == ayendeBlog.Id).ConvertAll(x => x.Id)); mythz.BlogIds.Add(mythzBlog.Id); mythzBlog.BlogPostIds.AddRange(blogPosts.Where(x => x.BlogId == mythzBlog.Id).ConvertAll(x => x.Id)); redisUsers.Store(ayende); redisUsers.Store(mythz); redisBlogs.StoreAll(new[] { ayendeBlog, mythzBlog }); redisBlogPosts.StoreAll(blogPosts); } }
public void InsertTestData() { using (var redisUsers = redisClient.GetTypedClient <User>()) using (var redisBlogs = redisClient.GetTypedClient <Blog>()) using (var redisBlogPosts = redisClient.GetTypedClient <BlogPost>()) { var ayende = new User { Id = redisUsers.GetNextSequence(), Name = "Oren Eini" }; var mythz = new User { Id = redisUsers.GetNextSequence(), Name = "Demis Bellot" }; var ayendeBlog = new Blog { Id = redisBlogs.GetNextSequence(), UserId = ayende.Id, UserName = ayende.Name, Tags = new List <string> { "Architecture", ".NET", "Databases" }, }; var mythzBlog = new Blog { Id = redisBlogs.GetNextSequence(), UserId = mythz.Id, UserName = mythz.Name, Tags = new List <string> { "Architecture", ".NET", "Databases" }, }; var blogPosts = new List <BlogPost> { new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = ayendeBlog.Id, Title = "RavenDB", Categories = new List <string> { "NoSQL", "DocumentDB" }, Tags = new List <string> { "Raven", "NoSQL", "JSON", ".NET" }, Comments = new List <BlogPostComment> { new BlogPostComment { Content = "First Comment!", CreatedDate = DateTime.UtcNow, }, new BlogPostComment { Content = "Second Comment!", CreatedDate = DateTime.UtcNow, }, } }, new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = mythzBlog.Id, Title = "Redis", Categories = new List <string> { "NoSQL", "Cache" }, Tags = new List <string> { "Redis", "NoSQL", "Scalability", "Performance" }, Comments = new List <BlogPostComment> { new BlogPostComment { Content = "First Comment!", CreatedDate = DateTime.UtcNow, } } }, new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = ayendeBlog.Id, Title = "Cassandra", Categories = new List <string> { "NoSQL", "Cluster" }, Tags = new List <string> { "Cassandra", "NoSQL", "Scalability", "Hashing" }, Comments = new List <BlogPostComment> { new BlogPostComment { Content = "First Comment!", CreatedDate = DateTime.UtcNow, } } }, new BlogPost { Id = redisBlogPosts.GetNextSequence(), BlogId = mythzBlog.Id, Title = "Couch Db", Categories = new List <string> { "NoSQL", "DocumentDB" }, Tags = new List <string> { "CouchDb", "NoSQL", "JSON" }, Comments = new List <BlogPostComment> { new BlogPostComment { Content = "First Comment!", CreatedDate = DateTime.UtcNow, } } }, }; ayende.BlogIds.Add(ayendeBlog.Id); ayendeBlog.BlogPostIds.AddRange(blogPosts.Where(x => x.BlogId == ayendeBlog.Id).ConvertAll(x => x.Id)); mythz.BlogIds.Add(mythzBlog.Id); mythzBlog.BlogPostIds.AddRange(blogPosts.Where(x => x.BlogId == mythzBlog.Id).ConvertAll(x => x.Id)); redisUsers.Store(ayende); redisUsers.Store(mythz); redisBlogs.StoreAll(new[] { ayendeBlog, mythzBlog }); redisBlogPosts.StoreAll(blogPosts); } }