Пример #1
0
        private static void Delete()
        {
            LearnEntityFrameworkDB db = new LearnEntityFrameworkDB();

            var product = db.Products.SingleOrDefault(p => p.Id == 6);

            db.Products.Remove(product);


            Console.WriteLine("Result: " + db.SaveChanges());
            Console.ReadLine();
        }
Пример #2
0
        private static void Update()
        {
            LearnEntityFrameworkDB db = new LearnEntityFrameworkDB();

            var product = db.Products.SingleOrDefault(p => p.Id == 6);

            product.Name   = "abc";
            product.Price  = 999;
            product.Status = false;

            Console.WriteLine("Result: " + db.SaveChanges());
            Console.ReadLine();
        }
Пример #3
0
        private static void Insert()
        {
            LearnEntityFrameworkDB db = new LearnEntityFrameworkDB();

            var product = new Product()
            {
                Name         = "Tivi 3",
                Price        = 12,
                Quantity     = 3,
                CreationDate = System.DateTime.Now,
                Status       = true,
                CategoryId   = 3
            };

            db.Products.Add(product);
            Console.WriteLine("Result: " + db.SaveChanges());
            Console.ReadLine();
        }