コード例 #1
0
 public virtual void Edit(T entity)
 {
     using (var dbContext = new LivescoreDbContext())
     {
         var dbSet = GetDbSet(dbContext);
         dbContext.Entry(entity).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
コード例 #2
0
 public virtual T Add(T entity)
 {
     using (var dbContext = new LivescoreDbContext())
     {
         dbContext.Entry(entity).State = EntityState.Added;
         dbContext.SaveChanges();
         return(entity);
     }
 }
コード例 #3
0
 public virtual void Delete(int id)
 {
     using (var dbContext = new LivescoreDbContext())
     {
         var dbSet  = GetDbSet(dbContext);
         var entity = dbSet.Find(id);
         dbContext.Entry(entity).State = EntityState.Deleted;
         dbContext.SaveChanges();
     }
 }