private void InsertTestData(IBlogRepository repository) { var ayende = new User {Name = "ayende"}; var mythz = new User {Name = "mythz"}; repository.StoreUsers(ayende, mythz); var ayendeBlog = ayende.CreateNewBlog(new Blog { Tags = { "Architecture", ".NET", "Databases" } }); var mythzBlog = mythz.CreateNewBlog(new Blog { Tags = { "Architecture", ".NET", "Databases" } }); ayendeBlog.StoreNewBlogPosts(new BlogPost { 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 { 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,} } }); mythzBlog.StoreNewBlogPosts( new BlogPost { 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 { 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,} } }); }
public void store_and_retrieve_some_blogs() { using (var users = redisClient.As<User>()) { using (var blogs = redisClient.As<Blog>()) { var mythz = new User { Id = users.GetNextSequence(), Name = "Demis Bellot" }; var mythzBlogs = new List<Blog> { new Blog { Id = blogs.GetNextSequence(), UserId = mythz.Id, UserName = mythz.Name, Tags = new List<string> {"Architecture", ".NET", "Redis"}, }, new Blog { Id = blogs.GetNextSequence(), UserId = mythz.Id, UserName = mythz.Name, Tags = new List<string> { "Music", "Twitter", "Life" }, }, }; mythzBlogs.ForEach(x=> mythz.BlogIds.Add(x.Id)); users.Store(mythz); blogs.StoreAll(mythzBlogs); var allBlogs = blogs.GetAll(); Console.WriteLine(allBlogs.Dump()); allBlogs.Count.ShouldEqual(2); } } }
private void InsertTestData() { using (var redisUsers = redisClient.As<User>()) { using (var redisBlogs = redisClient.As<Blog>()) { using (var redisBlogPosts = redisClient.As<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); } } } }