コード例 #1
0
 public void UpdateCategory(int catId, Category category)
 {
     var itemToUpdate = dbContext.Categories.SingleOrDefault(x => x.CategoryId == catId);
     if (itemToUpdate != null)
     {
         itemToUpdate = category;
         dbContext.SaveChanges();
     }
 }
コード例 #2
0
 public void AddNewCategory(Category category)
 {
     dbContext.Categories.Add(category);
     dbContext.SaveChanges();
 }