Пример #1
0
 private static void UpdateProductCategory()
 {
     using (var context = new AWEntities())
     {
         var existingCategory = context.ProductCategories.Find(1);
         existingCategory.Name = "Updated Category";
         Console.WriteLine(context.Entry(existingCategory).State);
     }
 }
Пример #2
0
 private static void DeleteProductCategory()
 {
     using (var context = new AWEntities())
     {
         var categoryToDelete = context.ProductCategories.Find(1);
         if (categoryToDelete != null)
         {
             context.ProductCategories.Remove(categoryToDelete);
             Console.WriteLine(context.Entry(categoryToDelete).State);
         }
     }
 }
Пример #3
0
        private static void AddNewProductCategory()
        {
            using (var context = new AWEntities())
            {
                var newCategory = new ProductCategory
                {
                    Name = "New Product Category"
                };
                context.ProductCategories.Add(newCategory);

                Console.WriteLine(context.Entry(newCategory).State);
            }
        }