コード例 #1
0
 public T Buscar(K chave)
 {
     using (var ctx = new ProjetoConnection())
     {
         return(ctx.Set <T>().Find(chave));
     }
 }
コード例 #2
0
 //public void Adicionar(T item)
 //{
 //    using (var ctx = new ProjetoConnection())
 //    {
 //        ctx.Entry<T>(item).State = EntityState.Added;
 //        ctx.SaveChanges();
 //    }
 //}
 //public void Alterar(T item)
 //{
 //    using (var ctx = new ProjetoConnection())
 //    {
 //        ctx.Entry<T>(item).State = EntityState.Modified;
 //        ctx.SaveChanges();
 //    }
 //}
 //public void Deletar(T item)
 //{
 //    using (var ctx = new ProjetoConnection())
 //    {
 //        ctx.Entry<T>(item).State = EntityState.Deleted;
 //        ctx.SaveChanges();
 //    }
 //}
 public IEnumerable <T> Listar()
 {
     using (var ctx = new ProjetoConnection())
     {
         return(ctx.Set <T>().ToList());
     }
 }