Пример #1
0
        static void Main(string[] args)
        {
            //Güncelleme işlemleri
            //LINQ (language integrated Query)
            UrunContext context = new UrunContext();

            var urun = context.Urunler.Find(1);

            urun.Fiyat     = urun.Fiyat + (urun.Fiyat * 0.5);
            urun.UrunAdi   = "Samsung s4";
            urun.StokAdeti = urun.StokAdeti + 100;

            context.SaveChanges();

            urun = context.Urunler.Find(1);

            Console.WriteLine("uru id :{0} urun adı : {1} fiyat : {2}", urun.Id, urun.UrunAdi, urun.Fiyat);


            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            //LINQ (language integrated Query)
            UrunContext context = new UrunContext();

            List <Urun> urunler = new List <Urun>()
            {
                new Urun()
                {
                    UrunAdi = "Huaweı Mate 10", Fiyat = 3000, StokAdeti = 3232
                },
                new Urun()
                {
                    UrunAdi = "Huaweı Mate 9", Fiyat = 3000, StokAdeti = 3232
                },
                new Urun()
                {
                    UrunAdi = "Huaweı Mate 8", Fiyat = 3000, StokAdeti = 3232
                },
                new Urun()
                {
                    UrunAdi = "Huaweı Mate 7", Fiyat = 3000, StokAdeti = 3232
                },
                new Urun()
                {
                    UrunAdi = "Huaweı Mate 6", Fiyat = 3000, StokAdeti = 3232
                },
            };

            foreach (var urun in urunler)
            {
                context.Urunler.Add(urun);
            }

            context.SaveChanges();
            Console.WriteLine("Kayıt edildi.");
            Console.ReadLine();
        }