Exemplo n.º 1
0
 public IList <Nome> Lista(String nome)
 {
     using (var contexto = new AgendaContext())
     {
         return(contexto.Nomes.Where(p => p.NomeContato.Contains(nome)).ToList());
     }
 }
Exemplo n.º 2
0
 public Email BuscaPorId(int id)
 {
     using (var contexto = new AgendaContext())
     {
         return(contexto.Emails.Find(id));
     }
 }
Exemplo n.º 3
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);
                //        }
                //    }

                //}
            }
        }
Exemplo n.º 4
0
 public Telefone BuscaPorId(int id)
 {
     using (var contexto = new AgendaContext())
     {
         return(contexto.Telefones.Find(id));
     }
 }
Exemplo n.º 5
0
 public IList <Email> Lista()
 {
     using (var contexto = new AgendaContext())
     {
         return(contexto.Emails.Include("NomeContato").ToList());
     }
 }
Exemplo n.º 6
0
 public IList <Telefone> Lista()
 {
     using (var contexto = new AgendaContext())
     {
         return(contexto.Telefones.Include("NomeContato").ToList());
     }
 }
Exemplo n.º 7
0
 public Nome BuscaPorId(int id)
 {
     using (var contexto = new AgendaContext())
     {
         return(contexto.Nomes.Find(id));
     }
 }
Exemplo n.º 8
0
 public IList <Nome> Lista()
 {
     using (var contexto = new AgendaContext())
     {
         return(contexto.Nomes.ToList());
     }
 }
Exemplo n.º 9
0
 public void Adiciona(Email email)
 {
     using (var context = new AgendaContext())
     {
         context.Emails.Add(email);
         context.SaveChanges();
     }
 }
Exemplo n.º 10
0
 public void Atualiza(Telefone telefone)
 {
     using (var contexto = new AgendaContext())
     {
         contexto.Entry(telefone).State = System.Data.Entity.EntityState.Modified;
         contexto.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public void Adiciona(Telefone telefone)
 {
     using (var context = new AgendaContext())
     {
         context.Telefones.Add(telefone);
         context.SaveChanges();
     }
 }
Exemplo n.º 12
0
 public void Adiciona(Nome nome)
 {
     using (var context = new AgendaContext())
     {
         context.Nomes.Add(nome);
         context.SaveChanges();
     }
 }