internal void GenerateRandomPeopleData(string dbName, string host, int numberOfEntities) { var dbController = new MongoDbController(dbName, host); var db = dbController.GetDatabase(); var collection = db.GetCollection<PersonMongo>("Person"); var personCollection = new List<PersonMongo>(); var countryGenerator = new CountriesCollection(); var randomGenerator = new RandomGenerator(); for (int i = 1; i <= numberOfEntities; i++) { personCollection.Add(new PersonMongo( i, randomGenerator.GetRandomString(3, 5, true), randomGenerator.GetRandomString(4, 7, true), GetGender(i), randomGenerator.GetRandomInt(1920,2015), countryGenerator.GetRandomCountry())); } collection.InsertManyAsync(personCollection); Console.Write("Press key"); Console.ReadKey(); Console.WriteLine("Person data created"); }
public void GenerateData(string dbName, string host, int numberOfEntities) { var dbController = new DbController(); var db = dbController.GetDatabase(dbName, host); var collection = db.GetCollection<PersonMongo>("Person"); var personCollection = new List<PersonMongo>(); var countryGenerator = new CountriesCollection(); for (int i = 1; i <= numberOfEntities; i++) { personCollection.Add(new PersonMongo(i, "FName" + i, "LastName" + i, GetGender(i), GetRandomYear(), countryGenerator.GetRandomCountry())); } collection.InsertManyAsync(personCollection); Console.Write("Press key"); Console.ReadLine(); Console.WriteLine("Person data created"); }