Esempio n. 1
0
        public void replication()
        {
            mongo.DeleteAllRecords <RouterModel>("router");
            CountryModel country = new CountryModel {
                Name = "TestCountry"
            };
            CompanyModel company = new CompanyModel {
                Name = "TestCompany"
            };
            EncriptionModel encription = new EncriptionModel {
                Name = "TestEncription"
            };
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < 1000; i++)
            {
                Insert(new RouterModel
                {
                    Name       = "Test",
                    Antennas   = 4,
                    Mac        = "Test",
                    Company    = company,
                    Country    = country,
                    Encription = encription
                });
            }
            stopwatch.Stop();
            Console.WriteLine($"Insert time is {stopwatch.ElapsedMilliseconds}");
            stopwatch.Start();
            mongo.LoadRecords <RouterModel>("router");
            stopwatch.Stop();
            Console.WriteLine($"Select time is {stopwatch.ElapsedMilliseconds}");
        }
        public void MigrateCountry()
        {
            //get all records from mongo
            var mongocountries = mongo.LoadRecords <CountryModel>("country");

            List <Country> countries = new List <Country>(mongocountries.Count);

            //adding countries to sql list
            foreach (var country in mongocountries)
            {
                var coun = new Country {
                    CountryName = country.Name
                };
                countries.Add(coun);
            }

            foreach (var country in countries)
            {
                dao.CreateCountry(country.CountryName);
            }
        }