예제 #1
0
 public IList <T> GetList()
 {
     using (var context = new ToDoListDbContext())
     {
         return(context.Set <T>().ToList());
     }
 }
예제 #2
0
 public T GetById(int id)
 {
     using (var context = new ToDoListDbContext())
     {
         return(context.Set <T>().Find(id));
     }
 }
예제 #3
0
 public void Update(T entity)
 {
     using (var context = new ToDoListDbContext())
     {
         var updateEntity = context.Entry(entity);
         updateEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #4
0
 public void Delete(T entity)
 {
     using (var context = new ToDoListDbContext())
     {
         var deleteEntity = context.Entry(entity);
         deleteEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
예제 #5
0
 public void Add(T entity)
 {
     using (var context = new ToDoListDbContext())
     {
         var addEntity = context.Entry(entity);
         addEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }