public void Create()
        {
            var dbUsr = CreateOrEditUser();

            using (var secDb = new SecDbContext())
            {
                secDb.Users.Add(dbUsr);
                secDb.SaveChanges();
            }
        }
 public void CreateAuto(int numToAdd)
 {
     using (var secDb = new SecDbContext())
     {
         Console.Write("[CipherDB] Adding user records " + Environment.NewLine + "[");
         for (int i = 0; i < numToAdd; i++)
         {
             secDb.Users.Add(CreateRandomUser());
             Console.Write(".");
         }
         Console.WriteLine("]");
         secDb.SaveChanges();
     }
 }
        public void DeleteAll()
        {
            using (var secDb = new SecDbContext())
            {
                int deleted = 0;
                foreach (var deleteThis in secDb.Users)
                {
                    secDb.Users.Remove(deleteThis);
                    deleted++;
                }

                var written = secDb.SaveChanges();
                Console.WriteLine("Deleted {0} entities, write to {1} entites", deleted, written);
            }
        }
 public void LiveMigrate()
 {
     using (var secDb = new SecDbContext())
     {
         foreach (User o in secDb.Users)
         {
             // If CipherDB detects any rows still using the old
             // encryption keys AND if Migration Policy allows it
             // track all such older rows.
         }
         // To minimize write pressure, CipherDB will update old
         // entities to newer the latest encryption key
         // ONLY when application generates a write, like below
         secDb.SaveChanges();
     }
 }
 public void Delete()
 {
     using (var secDb = new SecDbContext())
     {
         var id         = GetId();
         var deleteThis = secDb.Users.Find(id);
         if (deleteThis != null)
         {
             secDb.Users.Remove(deleteThis);
             secDb.SaveChanges();
         }
         else
         {
             Console.WriteLine("Order ID {0} not found!", id);
         }
     }
 }
 public void Update()
 {
     using (var secDb = new SecDbContext())
     {
         var id         = GetId();
         var beforeUser = secDb.Users.Find(id);
         if (beforeUser != null)
         {
             var afterUser = CreateOrEditUser(beforeUser);
             secDb.Entry(beforeUser).CurrentValues.SetValues(afterUser);
             secDb.SaveChanges();
         }
         else
         {
             Console.WriteLine("Order ID {0} not found!", id);
         }
     }
 }