コード例 #1
0
 public void Categories_Delete(Category removeItem)
 {
     using (ToolsContext context = new ToolsContext())
     {
         #region Student Code here
         //insert Delete code
         var existingvalue = context.Categories.Find(removeItem.CategoryID);
         context.Categories.Remove(existingvalue);
         context.SaveChanges();
         #endregion
     }
 }
コード例 #2
0
 public void Categories_Add(Category item)
 {
     using (ToolsContext context = new ToolsContext())
     {
         #region Student Code here
         //insert add code
         var adding = context.Categories.Add(item); context.SaveChanges();
         //replace the following line of code to return your results
         // return 0;
         #endregion
     }
 }
コード例 #3
0
 public void Categories_Update(Category item)
 {
     using (ToolsContext context = new ToolsContext())
     {
         #region Student Code here
         //insert udpate code
         var updating = context.Categories.Attach(item);
         var matchingWithExistingValues = context.Entry<Category>(updating);
         matchingWithExistingValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         #endregion
     }
 }