コード例 #1
0
 public virtual T Selecionar(int id)
 {
     using (var contexto = new BaseContexto())
     {
         return(contexto.Set <T>().Find(id));
     }
 }
コード例 #2
0
 public virtual IList <T> Listar()
 {
     using (var contexto = new BaseContexto())
     {
         return(contexto.Set <T>().ToList());
     }
 }
コード例 #3
0
 public virtual void Atualiza(T item)
 {
     using (var contexto = new BaseContexto())
     {
         contexto.Entry(item).State = System.Data.Entity.EntityState.Modified;
         contexto.SaveChanges();
     }
 }
コード例 #4
0
 public virtual void Excluir(T item)
 {
     using (var contexto = new BaseContexto())
     {
         contexto.Entry <T>(item).State = EntityState.Deleted;
         contexto.SaveChanges();
     }
 }
コード例 #5
0
 public virtual void Adicionar(T item)
 {
     using (var contexto = new BaseContexto())
     {
         contexto.Set <T>().Add(item);
         contexto.SaveChanges();
     }
 }
コード例 #6
0
 public virtual IList <T> Listar <T>(params Expression <Func <T, object> >[] includes) where T : class
 {
     using (var contexto = new BaseContexto())
     {
         var query = contexto.Set <T>().AsQueryable();
         foreach (var include in includes)
         {
             query = query.Include(include);
         }
         return(query.AsNoTracking().ToList());
     }
 }