Пример #1
0
 public void Update(Color entity)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #2
0
 public void Add(Color entity)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Пример #3
0
 public void Delete(Color entity)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Пример #4
0
 public void Update(Product entity)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #5
0
 public void Add(Product entity)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = Microsoft.EntityFrameworkCore.EntityState.Added;
         context.SaveChanges();
     }
 }
Пример #6
0
 public void Add(Product entity)
 {
     //IDisposable pattern implementation of c#
     using (NorthWindContext context = new NorthWindContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Пример #7
0
 public void Update(Product entity)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         //git veri kaynagindan gonderdigim productan bir nesneye eslestir ama yeni ekleme oldugu icin direkt ekler
         //bu referansi yakalama
         var updatedEntity = context.Entry(entity);
         //Simdi bu nesneyi napacagiz?
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #8
0
 public void Add(Product entity)
 {
     //csharpa ozel biz bi klassi newledigimizede Garbage collector brlli bir zaman sonra duzenli olarak onu atar
     //using icindeki nesneler using bitince aninda garbage collectora derki beni at cunku context nesnesi biraz pahali
     //IDisposable Pattern Implementation of C#
     using (NorthWindContext context = new NorthWindContext())
     {
         //git veri kaynagindan gonderdigim productan bir nesneye eslestir ama yeni ekleme oldugu icin direkt ekler
         //bu referansi yakalama
         var addedEntity = context.Entry(entity);
         //Simdi bu nesneyi napacagiz?
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }