예제 #1
0
 public T Edit <T>(T entity) where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         context.Entry(entity).State = EntityState.Modified;
         context.SaveChanges();
         return(entity);
     }
 }
예제 #2
0
 public bool EditAll <T>(List <T> entityList) where T : class
 {
     using (var context = new OnlineTestContext(_dbContextOptionBuilder.Options))
     {
         try
         {
             foreach (var entity in entityList)
             {
                 context.Entry(entity).State = EntityState.Modified;
             }
             context.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }