Guest User

Untitled

a guest
Apr 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. Mongo mongo = new Mongo();
  6. mongo.Connect();
  7. Database db = mongo["testdb"];
  8.  
  9. Random rand = new Random();
  10. IMongoCollection docs = db.GetCollection("docs");
  11.  
  12. //for (int i = 0; i < 100; ++i)
  13. //{
  14. // Document doc = new Document();
  15. // StringBuilder sb = new StringBuilder();
  16. // doc["title"] = Guid.NewGuid().ToString();
  17. // doc["author"] = rand.Next() % 10;
  18. // docs.Insert(doc);
  19. //}
  20. Document doc = new Document();
  21. doc["author"] = 1;
  22. foreach (Document hit in docs.Find(doc).Documents)
  23. {
  24. Console.WriteLine("{0} {1} {2}", hit["author"], hit["name"], hit["title"]);
  25. }
  26.  
  27. Console.ReadLine();
  28. }
  29. }
Add Comment
Please, Sign In to add comment