Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected ProjetoCarteiraWebContexto bd = new ProjetoCarteiraWebContexto();
- public void Adicionar(TEntity objeto)
- {
- bd.Set<TEntity>().Add(objeto);
- bd.SaveChanges();
- }
- public void Alterar(TEntity objeto)
- {
- bd.Entry(objeto).State = System.Data.Entity.EntityState.Modified;
- bd.SaveChanges();
- }
- public TEntity ConsultarPorId(int id)
- {
- return bd.Set<TEntity>().Find(id);
- }
- public IEnumerable<TEntity> ConsultarTodos()
- {
- return bd.Set<TEntity>().ToList();
- }
- public void Remover(TEntity objeto)
- {
- bd.Set<TEntity>().Remove(objeto);
- bd.SaveChanges();
- }
- public void Dispose()
- {
- bd.Dispose();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement