示例#1
0
        public override void Generate()
        {
            Console.WriteLine("Adding AgeRanges:");
            int count = 0;

            for (int i = 0; i < this.Count / 5; i++)
            {
                for (int j = 1 + 1; j <= i + 5; j++)
                {
                    var newAgeRange = new AgeRanx
                    {
                        MinimumAge = i,
                        MaximumAge = j
                    };

                    this.Database.AgeRanges.Add(newAgeRange);

                    count++;

                    if (count % 100 == 0)
                    {
                        this.Database.SaveChanges();
                    }

                    if (count == this.Count)
                    {
                        Console.WriteLine();
                        Console.WriteLine("AgeRanges added!");
                        return;
                    }
                }
            }
        }
示例#2
0
        public override void Generate()
        {
            Console.WriteLine("Adding age ranges...");
            int count = 0;

            for (int i = 0; i < this.Count / 5; i++)
            {
                for (int j = i + 1; j < i + 5; j++)
                {
                    var ageRange = new AgeRanx
                    {
                        MinimumAge = i,
                        MaximumAge = j,
                    };

                    this.Database.AgeRanges.Add(ageRange);
                    count++;

                    if (count % 100 == 0)
                    {
                        Console.Write(".");
                        this.Database.SaveChanges();
                    }

                    if (count == this.Count)
                    {
                        Console.WriteLine("\nAge ranges added");
                        return;
                    }
                }
            }
        }
        public override void Generate(int count)
        {
            var counter = 0;

            for (int i = 0; i < count / 5; i++)
            {
                for (int j = i + 1; j <= i + 5; j++)
                {
                    var ageRange = new AgeRanx()
                    {
                        AgeFrom = i,
                        AgeTo   = j
                    };

                    this.Db.AgeRanges.Add(ageRange);

                    counter++;

                    if (counter % 100 == 0)
                    {
                        this.Db.SaveChanges();
                    }

                    if (counter == count)
                    {
                        return;
                    }
                }
            }
        }
        public override void Generate()
        {
            int count = 0;
            Console.WriteLine("Adding age ranges");

            for (int i = 0; i < this.Count / 5; i++)
            {
                for (int j = i + 1; j <= i + 5; j++)
                {
                    var ageRange = new AgeRanx
                    {
                        MinimumAge = i,
                        MaximumAge = j
                    };

                    this.Database.AgeRanges.Add(ageRange);
                    count++;

                    if (count % 100 == 0)
                    {
                        Console.Write(".");
                        this.Database.SaveChanges();
                    }

                    if (count == this.Count)
                    {
                        Console.WriteLine("\nAge ranges added");
                        return;
                    }
                }
            }
        }
示例#5
0
        public override void SeedDatabase()
        {
            for (int i = 0; i < AgeRangesCount; i++)
            {
                var ageRange = new AgeRanx
                {
                    MinAge = this.NumberGenerator.GetRandomInteger(0, 7),
                    MaxAge = this.NumberGenerator.GetRandomInteger(8, 13)
                };

                this.AgeRangesRepository.Add(ageRange);
            }

            using (var unitOfWork = this.UnitOfWork())
            {
                unitOfWork.Save();
            }
        }