Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MongoConnectionStress
- {
- class Program
- {
- private static MongoClient mongoClient;
- private static MongoServer server;
- private static MongoDatabase database;
- static void Connect()
- {
- mongoClient = new MongoClient("mongodb://USER:PASS@SERVERADDRESS:PORT/Database");
- server = mongoClient.GetServer();
- database = server.GetDatabase("employeelife");
- }
- static void Main(string[] args)
- {
- Connect();
- var count = 0;
- var RyansTest = database.GetCollection<ELModels.TestModal>("RYANSTEST");
- for (int i = 0; i < 10000; i++)
- {
- try
- {
- ELModels.TestModal test = new ELModels.TestModal();
- test.name = "TEST";
- test.age = new Random().Next(1, 99);
- test.alive = true;
- RyansTest.Save(test);
- Console.WriteLine("Saved : " + i + " " + test._id.ToString());
- }
- catch (Exception)
- {
- Console.WriteLine("Failed " + i);
- }
- }
- Console.WriteLine("Done" + count);
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment