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