コード例 #1
0
 public List <Category> GetCategories()
 {
     using (var context = new ClothShopContext())
     {
         return(context.Categories.ToList());
     }
 }
コード例 #2
0
 public Category GetCategory(int ID)
 {
     using (var context = new ClothShopContext())
     {
         return(context.Categories.Find(ID));
     }
 }
コード例 #3
0
 public void UpdateCategory(Category category)
 {
     using (var context = new ClothShopContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #4
0
 public void SaveCategory(Category category)
 {
     using (var context = new ClothShopContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
コード例 #5
0
        public void DeleteCategory(int ID)
        {
            using (var context = new ClothShopContext())
            {
                // context.Entry(category).State = System.Data.Entity.EntityState.Deleted;

                var category = context.Categories.Find(ID);
                context.Categories.Remove(category);
                context.SaveChanges();
            }
        }