Beispiel #1
0
        public void ExplicitLoading()
        {
            using (var context = new EfContext())
            {
                var client = context.Clients.Find(3);

                context.Entry(client)
                    .Reference(x => x.Category)
                    .Load();

                context.Entry(client)
                    .Collection(x => x.Payments)
                    .Load();
            }
        }
Beispiel #2
0
        private void generateClients()
        {
            for (var i = 0; i < 500; i++)
            {
                using (var context = new EfContext())
                {
                    context.Configuration.AutoDetectChangesEnabled = false;
                    context.Configuration.ValidateOnSaveEnabled = false;

                    for (var j = 0; j < 1000; j++)
                    {
                        var client = new Client
                            {
                                Name = "client" + i + "_" + j,
                                Changed = DateTime.Now,
                                CategoryId = ((j*3 + j/7)%100) + 1,
                                GroupId = ((j*5 + j/11)%100) + 1
                            };
                        context.Entry(client).State = EntityState.Added;
                    }

                    context.SaveChanges();
                }
            }
        }
Beispiel #3
0
        private void generateGroups()
        {
            using (var context = new EfContext())
            {
                context.Configuration.AutoDetectChangesEnabled = false;
                context.Configuration.ValidateOnSaveEnabled = false;

                for (int i = 0; i < 100; i++)
                {
                    var group = new RiskGroup {Name = "group" + i};
                    context.Entry(group).State = EntityState.Added;
                }

                context.SaveChanges();
            }
        }
Beispiel #4
0
        private void generateCategories()
        {
            using (var context = new EfContext())
            {
                context.Configuration.AutoDetectChangesEnabled = false;
                context.Configuration.ValidateOnSaveEnabled = false;

                for (int i = 0; i < 100; i++)
                {
                    var category = new Category { Name = "category" + i };
                    context.Entry(category).State = EntityState.Added;
                }

                context.SaveChanges();
            }
        }