Beispiel #1
0
 public IQueryable <TEntity> GetAll()
 {
     try
     {
         return(_clienteDbContext.Set <TEntity>());
     }
     catch (Exception ex)
     {
         throw new Exception($"Couldn't retrieve entities: {ex.Message}");
     }
 }
Beispiel #2
0
 public IList <T> Listar()
 {
     using (var db = new ClienteDbContext(_optionsBuilder))
     {
         return(db.Set <T>().AsNoTracking().ToList());
     }
 }
Beispiel #3
0
 public T RecuperarPorId(Guid id)
 {
     using (var db = new ClienteDbContext(_optionsBuilder))
     {
         return(db.Set <T>().Find(id));
     }
 }
Beispiel #4
0
 public void Excluir(T obj)
 {
     using (var db = new ClienteDbContext(_optionsBuilder))
     {
         db.Set <T>().Remove(obj);
         db.SaveChanges();
     }
 }
Beispiel #5
0
 public void Atualizar(T obj)
 {
     using (var db = new ClienteDbContext(_optionsBuilder))
     {
         db.Set <T>().Update(obj);
         db.SaveChanges();
     }
 }
Beispiel #6
0
 public void Adicionar(T obj)
 {
     using (var db = new ClienteDbContext(_optionsBuilder))
     {
         db.Set <T>().Add(obj);
         db.SaveChanges();
     }
 }
Beispiel #7
0
        public async Task CreateAsync(TEntity entity)
        {
            await _db.Set <TEntity>().AddAsync(entity);

            await _db.SaveChangesAsync();
        }
Beispiel #8
0
 public BaseRepository(ClienteDbContext context)
 {
     _clienteDbContext = context;
     DbSet             = _clienteDbContext.Set <TEntity>();
 }