public virtual T Selecionar(int id) { using (var contexto = new BaseContexto()) { return(contexto.Set <T>().Find(id)); } }
public virtual IList <T> Listar() { using (var contexto = new BaseContexto()) { return(contexto.Set <T>().ToList()); } }
public virtual void Adicionar(T item) { using (var contexto = new BaseContexto()) { contexto.Set <T>().Add(item); contexto.SaveChanges(); } }
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()); } }