public T Buscar(K chave) { using (var ctx = new ProjetoConnection()) { return(ctx.Set <T>().Find(chave)); } }
//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()); } }