public void InsertTest() { var watch = new Stopwatch(); watch.Start(); //MongoClient client = new MongoClient("mongodb://10.211.55.2"); // connect to localhost MongoClient client = new MongoClient(Utils.MongoDbConnection); MongoServer server = client.GetServer(); MongoDatabase test = server.GetDatabase("mydb"); var result = test.GetCollection("address"); //var r = result.FindAs<DireccionMongo>() Random ran = new Random(DateTime.Now.Millisecond); for (int i = 0; i < 1000000; i++) { AddressMongo direccion = new AddressMongo(); direccion.Street = Path.GetRandomFileName(); direccion.ZipCode = ran.Next(5000).ToString(); direccion.Coordinates = new Domain.XYPoint(ran.NextDouble() + ran.Next(60, 70), ran.NextDouble() + ran.Next(20, 30)); direccion.Date = DateTime.Now.AddYears(-1 * ran.Next(100)); direccion.TextReference = Path.GetRandomFileName() + Path.GetRandomFileName() + Path.GetRandomFileName(); result.Insert <AddressMongo>(direccion); } watch.Stop(); Console.Out.WriteLine("Total de segundos {0:N}", watch.Elapsed.TotalSeconds); //result.Drop(); }
public ShopperProfile() { this.CreateMap <Shopper, ShopperMongo>() .ConstructUsing(s => ShopperMongo.CreateNew(s.Gender, s.Id, s.FirstName, s.LastName, s.Email, null)); this.CreateMap <Address, AddressMongo>() .ConstructUsing(a => AddressMongo.Create(a.ID, a.Street, a.Number, a.City, a.Zip, a.Country, a.DateCreated)); }
private static void InsertMongo(int total) { MongoClient client = new MongoClient(Utils.MongoDbConnection); MongoServer server = client.GetServer(); MongoDatabase test = server.GetDatabase("mydb"); var result = test.GetCollection("address"); Random ran = new Random(DateTime.Now.Millisecond); Console.WriteLine(); for (int i = 0; i < total; i++) { Console.Write("\r{0:N2}% ", (i + 1) / Convert.ToDouble(total) * 100); AddressMongo direccion = new AddressMongo(); direccion.Street = Path.GetRandomFileName(); direccion.ZipCode = ran.Next(5000).ToString(); direccion.Coordinates = new Domain.XYPoint(ran.NextDouble() + ran.Next(60, 70), ran.NextDouble() + ran.Next(20, 30)); direccion.Date = DateTime.Now.AddYears(-1 * ran.Next(100)); direccion.TextReference = Path.GetRandomFileName() + Path.GetRandomFileName() + Path.GetRandomFileName(); result.Insert <AddressMongo>(direccion); } Console.WriteLine(); }