コード例 #1
0
        public void Atualiza(Email email)
        {
            using (var contexto = new AgendaContext())
            {
                //try
                //{
                contexto.Entry(email).State = System.Data.Entity.EntityState.Modified;
                contexto.SaveChanges();
                //}
                //catch (DbEntityValidationException e)
                //{
                //    foreach (var eve in e.EntityValidationErrors)
                //    {
                //        System.Diagnostics.Debug.WriteLine("Entidade do tipo \"{0}\" com estado \"{1}\" tem os seguintes erros de validação:",
                //            eve.Entry.Entity.GetType().Name, eve.Entry.State);
                //        foreach (var ve in eve.ValidationErrors)
                //        {
                //            System.Diagnostics.Debug.WriteLine("- Propriedade: \"{0}\", Error: \"{1}\"",
                //                ve.PropertyName, ve.ErrorMessage);
                //        }
                //    }

                //}
            }
        }
コード例 #2
0
 public void Adiciona(Email email)
 {
     using (var context = new AgendaContext())
     {
         context.Emails.Add(email);
         context.SaveChanges();
     }
 }
コード例 #3
0
 public void Adiciona(Telefone telefone)
 {
     using (var context = new AgendaContext())
     {
         context.Telefones.Add(telefone);
         context.SaveChanges();
     }
 }
コード例 #4
0
 public void Atualiza(Telefone telefone)
 {
     using (var contexto = new AgendaContext())
     {
         contexto.Entry(telefone).State = System.Data.Entity.EntityState.Modified;
         contexto.SaveChanges();
     }
 }
コード例 #5
0
 public void Adiciona(Nome nome)
 {
     using (var context = new AgendaContext())
     {
         context.Nomes.Add(nome);
         context.SaveChanges();
     }
 }