Example #1
0
        private void PocoCUD_Batch(string connectionString)
        {
            using (var context = CreateContext(connectionString))
            {
                using (context.Database.AsRelational().Connection.BeginTransaction())
                {
                    var customers = context.Customers.ToList();
                    foreach (var customer in customers)
                    {
                        customer.Name = "Updated Name";
                    }

                    foreach (var orderLineEntry in context.ChangeTracker.Entries <OrderLine>())
                    {
                        orderLineEntry.State = EntityState.Deleted;
                    }

                    CudContext.InsertTestingData(context);

                    context.SaveChanges();
                }
            }
        }