Exemple #1
0
 public T RecuperarPorId(Guid id)
 {
     using (var db = new ClientesDbContext(_optionsBuilder))
     {
         return(db.Set <T>().Find(id));
     }
 }
Exemple #2
0
 public IList <T> Listar()
 {
     using (var db = new ClientesDbContext(_optionsBuilder))
     {
         return(db.Set <T>().AsNoTracking().ToList());
     }
 }
Exemple #3
0
 public void Excluir(T obj)
 {
     using (var db = new ClientesDbContext(_optionsBuilder))
     {
         db.Set <T>().Remove(obj);
         db.SaveChanges();
     }
 }
Exemple #4
0
 public void Atualizar(T obj)
 {
     using (var db = new ClientesDbContext(_optionsBuilder))
     {
         db.Set <T>().Update(obj);
         db.SaveChanges();
     }
 }
Exemple #5
0
 public void Adicionar(T obj)
 {
     using (var db = new ClientesDbContext(_optionsBuilder))
     {
         db.Set <T>().Add(obj);
         db.SaveChanges();
     }
 }
Exemple #6
0
 public void Adicionar(T obj)
 {
     using (var db = new ClientesDbContext(_optionsBuilder))
     {
         try
         {
             db.Set <T>().Add(obj);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
 }