Exemplo n.º 1
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext()
            ) //ETradeContext pahalı bir nesne bu bağlamda method bittiği zaman bellekten atar GarbageCollector Dispose yapar direk!!!
     {
         //context.Products.Add(product); //Ekleme yapmak için Add çağırdık ve değişenleri kaydet dedik.
         var entity = context.Entry(product); //contexte abone ol product için gönderdiğimiz productu veritabanındaki product ile eşitliyor
         entity.State = EntityState.Added;    //id üzerinden eşitler primary key olduğu için
         context.SaveChanges();
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         context.Products.Add(product); //context deki products a product ekle
         context.SaveChanges();         //veri tabanına yaz
     }
 }
Exemplo n.º 3
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         context.Products.Add(product); // içine verdiğimiz nesneyi ekliyor.
         context.SaveChanges();         // yaptığımız işlemleri commit ediyoruz.
     }
 }
Exemplo n.º 4
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public void Update(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product); //uygulamadan girdi olarak gönderdiğimiz product ı veri tabanındakiyle eşitliyor
         entity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product); //gönderdiğin productı veritabanındaki ile eşitliyor
         entity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public void Update(Product product)
 {
     using (ETradeContext eTradeContext = new ETradeContext())
     {
         var entity = eTradeContext.Entry(product);
         entity.State = EntityState.Modified;
         eTradeContext.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public void Update(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product); // context'e bu product üzerinden ilerle
         entity.State = EntityState.Modified; // Modified -> update eder
         context.SaveChanges();
     }
 }
Exemplo n.º 9
0
 public void Update(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product); // veritabanına götürüp bekletiyor
         entity.State = EntityState.Modified; // bekletilen ürüne burada işlem yapıyoruz
         context.SaveChanges();
     }
 }
Exemplo n.º 10
0
 public void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product);
         entity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext()) //Nesneyi zorla bellekten atarak garbage collector ı beklemeden boşaltır.
     {
         var entity = context.Entry(product);
         entity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Exemplo n.º 12
0
 public void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product);
         entity.State = System.Data.Entity.EntityState.Deleted;//EntityState de yer alan silme fonksiyonu çalıştırılır.
         context.SaveChanges();
     }
 }
Exemplo n.º 13
0
 public void Update(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product);
         entity.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 14
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product);                 //oluşturulan var entity contextle bağlantı kurup gönderilen parametreyi karşılaştırılır.
         entity.State = System.Data.Entity.EntityState.Added; //EntityState de yer alan ekleme fonksiyonu çalıştırılır.
         context.SaveChanges();                               //değişiklikler kaydedilir.
     }
 }
Exemplo n.º 15
0
 public void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product); //contexte abone ol product için gönderdiğimiz productu veritabanındaki product ile eşitliyor
         entity.State = EntityState.Deleted;  //id üzerinden eşitler primary key olduğu için
         context.SaveChanges();
     }
 }
Exemplo n.º 16
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         //context.Products.Add(product);
         var entity = context.Entry(product);
         entity.State = System.Data.Entity.EntityState.Added;
         context.SaveChanges();//Yapılan değişiklikleri kaydeder
     }
 }
Exemplo n.º 17
0
 public void Add(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         //context.Products.Add(product);
         var entity = context.Entry(product);
         entity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Exemplo n.º 18
0
 public void Update(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         // context üzerinden abone ol
         var entity = context.Entry(product);
         entity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 19
0
 public void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         //primary key id üzerinden eşitler.
         var entity = context.Entry(product); //context'e abone ol. Kim için? -> parametre gelen product için
         entity.State = EntityState.Deleted;  //güncellendi işaretliyoruz.
         context.SaveChanges();
     }
 }
Exemplo n.º 20
0
 public void Add(Product product)
 {
     /*using kullanarak dispose işlemi yapılır garbage collector çalışır. Method bitince memory temizlenir.*/
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product);
         entity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Exemplo n.º 21
0
 internal void Delete(Product product)
 {
     using (ETradeContext context = new ETradeContext())
     {
         var entity = context.Entry(product);
         //context'e product için abone olup eşitle
         entity.State = EntityState.Deleted;
         //durumunu da sil demek
         context.SaveChanges();
     }
 }
Exemplo n.º 22
0
 internal void Add(Product product) //add ve get all daha erişilebilir olduğu için internal yapmak zorunda kaldım
 {
     using (ETradeContext context = new ETradeContext())
     {
         //context.Products.Add(product); bu da olur
         var entity = context.Entry(product); //bu da olur
         //context'e product için abone olup eşitle
         entity.State = EntityState.Added;
         //durumuna da ekle demek
         context.SaveChanges();
     }
 }
Exemplo n.º 23
0
        public void Add(Product product)
        {
            using (ETradeContext context = new ETradeContext())
            {
                context.Products.Add(product);
                context.SaveChanges();

                //yada aşağıdaki gibide yazabiliriz.

                //var entity = context.Entry(product);
                //entity.State = EntityState.Added;
                //context.SaveChanges();
            }
        }