/// <summary> /// /// </summary> /// <param name="numberOfItemsToCreate">The number of test posts to create</param> /// <param name="commentLimit">The upper limit of the number of random comments to create per post</param> public static void Run(int numberOfItemsToCreate, int commentLimit) { Console.WriteLine(String.Format("InitializeDatabase")); List<Post> posts = new List<Post>(); var repo = new MongoData(); repo.Clean(); for (int i = 0; i < numberOfItemsToCreate; i++) { var post = CreateTestPost("Discussion " + i, "email" + i + "@here.com", commentLimit); posts.Add(post); } Console.WriteLine(String.Format("\tTotal posts[{0}] and comments[{1}]",posts.Count(),posts.Sum(post => post.Comments.Count()))); DateTime start = DateTime.Now; repo.SaveBatch(posts); //repo.Save(posts); DateTime end = DateTime.Now; Console.WriteLine(String.Format("\tTime to insert {0} items:{1} seconds. {2} per insert" , (posts.Count() + posts.Sum(post => post.Comments.Count())) , (end - start).TotalSeconds , (end - start).TotalSeconds/ (posts.Count() + posts.Sum(post => post.Comments.Count())))); Console.WriteLine(String.Format("\tCreated MongoDB {0} with {1} rows", MongoData.MongoDbName, numberOfItemsToCreate)); repo.SaveManuscript(CreateTestWord()); repo.SaveManuscript(CreateTestExcel()); }
public static void Run() { var repo = new MongoData(); try { repo.Connect(); InitializeDatabase.Run(10, 10); repo.GetAllPosts(); repo.GetAllManuscripts(); repo.GetAllManuscriptsAsJson(); repo.GetAllExcel(); repo.QueryBlogCount(); var post = repo.QueryBlogByTitle("Discussion 2"); repo.Update(post); repo.QueryBlogBodyContaining("!"); repo.QueryCommentsBodyContaining("s"); repo.QueryWordByName("WordName"); repo.QueryExcelByName("ExcelName"); } finally { Console.WriteLine("Finished"); repo.Disconnect(); } }
public void Execute() { var repo = new MongoData(); repo.GetAllPosts(); }