示例#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 Adicionar(T item)
 {
     using (var contexto = new BaseContexto())
     {
         contexto.Set <T>().Add(item);
         contexto.SaveChanges();
     }
 }
示例#4
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());
     }
 }