Ejemplo n.º 1
0
        public void SeedGitUsers(int amount = 10000, bool tuned = false)
        {
            var data = Builder <GitHubResume> .CreateListOfSize(amount).All()
                       .With(c => c.PiplMatchedDate = Faker.Date.Past())
                       .With(c => c.Login           = Faker.User.Username())
                       .With(c => c.Location        = Faker.Address.SecondaryAddress())
                       .With(c => c.Name            = Faker.Name.FullName())
                       .With(c => c.Bio             = Faker.Lorem.Paragraph(10))
                       .With(c => c.Email           = Faker.User.Email())
                       .Build();

            using (var context = new GitDbContext())
            {
                if (tuned)
                {
                    context.BulkInsertAsync(data, amount).Wait();
                }
                else
                {
                    context.GitHubResumes.AddRange(data);
                    context.SaveChanges();
                }
                // EFBatchOperation.For(context, context.GitHubResumes).InsertAll(data);
                //context.AttachAndModify(data);
                //context.BulkInsert(data);
                //context.GitHubResumes.AddRange(data);
                // context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void SeedRandomContact(int count = 100000)
        {
            var rand = new Random();

            using (var context = new GitDbContext())
            {
                var ids        = context.GitHubResumes.OrderBy(x => Guid.NewGuid()).Take(count).Select(x => x.Id).ToList();
                var toSaveList = new List <ContactData>();
                foreach (var id in ids)
                {
                    var amount = rand.Next(1, 5);
                    for (var i = 0; i < amount; i++)
                    {
                        var cd = new ContactData()
                        {
                            GitHubResumeId = id, ContactType = (ContactType)rand.Next(2)
                        };
                        if (cd.ContactType == ContactType.Address)
                        {
                            cd.Data = Faker.Address.SecondaryAddress();
                        }
                        else if (cd.ContactType == ContactType.Email)
                        {
                            cd.Data = Faker.User.Email();
                        }
                        else
                        {
                            cd.Data = Faker.Number.RandomNumber(950000000, 959999999).ToString();
                        }
                        cd.PersonalKey = Faker.User.Password(10, true);
                        toSaveList.Add(cd);
                    }
                }
                //context.ContactDatas.AddRange(toSaveList)
                context.BulkInsertAsync(toSaveList).Wait();
            }
        }