public virtual IEnumerable <T> CapturarPor(Expression <Func <T, bool> > condicao) { using (ContainerControlContext dao = new ContainerControlContext()) { return(dao.Set <T>().Where(condicao).ToList()); } }
public virtual T CapturarPorId(Guid id) { using (ContainerControlContext dao = new ContainerControlContext()) { return(dao.Set <T>().FirstOrDefault(c => c.Id == id)); } }
public virtual IEnumerable <T> Listar() { using (ContainerControlContext dao = new ContainerControlContext()) { return(dao.Set <T>().ToList()); } }
public virtual T Atualizar(T model) { T entity = null; using (ContainerControlContext dao = new ContainerControlContext()) { entity = dao.Set <T>().Attach(model); dao.Entry(entity).State = EntityState.Modified; dao.SaveChanges(); } return(entity); }
public virtual T Inserir(T model) { T entity = null; using (ContainerControlContext dao = new ContainerControlContext()) { entity = dao.Set <T>().Add(model); dao.Entry(entity).State = EntityState.Added; dao.SaveChanges(); } return(entity); }