Example #1
0
 public virtual IEnumerable <T> CapturarPor(Expression <Func <T, bool> > condicao)
 {
     using (ContainerControlContext dao = new ContainerControlContext())
     {
         return(dao.Set <T>().Where(condicao).ToList());
     }
 }
Example #2
0
 public virtual T CapturarPorId(Guid id)
 {
     using (ContainerControlContext dao = new ContainerControlContext())
     {
         return(dao.Set <T>().FirstOrDefault(c => c.Id == id));
     }
 }
Example #3
0
 public virtual IEnumerable <T> Listar()
 {
     using (ContainerControlContext dao = new ContainerControlContext())
     {
         return(dao.Set <T>().ToList());
     }
 }
Example #4
0
        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);
        }
Example #5
0
        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);
        }