public void Update(Color entity) { using (NorthWindContext context = new NorthWindContext()) { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
public void Add(Color entity) { using (NorthWindContext context = new NorthWindContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }
public void Delete(Color entity) { using (NorthWindContext context = new NorthWindContext()) { var deletedEntity = context.Entry(entity); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Update(Product entity) { using (NorthWindContext context = new NorthWindContext()) { var updatedEntity = context.Entry(entity); updatedEntity.State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); } }
public void Add(Product entity) { using (NorthWindContext context = new NorthWindContext()) { var addedEntity = context.Entry(entity); addedEntity.State = Microsoft.EntityFrameworkCore.EntityState.Added; context.SaveChanges(); } }
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(); } }
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(); } }
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(); } }