public List <Color> GetAll(Expression <Func <Color, bool> > filter = null) { using (NorthWindContext context = new NorthWindContext()) { return(filter == null?context.Set <Color>().ToList() : context.Set <Color>().Where(filter).ToList()); } }
public Product Get(Expression <Func <Product, bool> > filter) { using (NorthWindContext context = new NorthWindContext()) { return(context.Set <Product>().SingleOrDefault(filter)); } }
public Color Get(Expression <Func <Color, bool> > filter) { using (NorthWindContext context = new NorthWindContext()) { return(context.Set <Color>().SingleOrDefault(filter)); } }
public Brand Get(Expression <Func <Brand, bool> > filter) { using (NorthWindContext context = new NorthWindContext()) { return(context.Set <Brand>().SingleOrDefault(filter)); } }
public void Update(Color entity) { using (NorthWindContext context = new NorthWindContext()) { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; 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 Add(Color entity) { 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()) { 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 List <Product> GetAll(Expression <Func <Product, bool> > filter = null) { using (NorthWindContext context = new NorthWindContext()) { //arka planda select* from products calistirir ve tolist e cevirir //filtre olarak gonderecegimiz sey bir lambda return(filter == null?context.Set <Product>().ToList() : context.Set <Product>().Where(filter).ToList()); } }
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(); } }