public void Update(T entity) { using var context = new ExamContext(); context.Set <T>().Update(entity); context.SaveChanges(); }
public T GetById(int id) { using var context = new ExamContext(); return(context.Set <T>().Find(id)); }
public List <T> GetAll() { using var context = new ExamContext(); return(context.Set <T>().ToList()); }
public void Delete(T entity) { using var context = new ExamContext(); context.Set <T>().Remove(entity); context.SaveChanges(); }
public Repository(ExamContext _context) { this._context = _context; this._dbSet = _context.Set <TEntity>(); }
public TEntity Get(int id) { // Here we are working with a DbContext, not PlutoContext. So we don't have DbSets // such as Courses or Authors, and we need to use the generic Set() method to access them. return(Context.Set <TEntity>().Find(id)); }