public List <Brand> GetAll(Expression <Func <Brand, bool> > filter = null) { using (RentACarContext context = new RentACarContext()) // IDisposable pattern implementation of c#. using ile daha performanslı. iş bitince garbage collector siler. { return(filter == null?context.Set <Brand>().ToList() : context.Set <Brand>().Where(filter).ToList()); } }
public Brand Get(Expression <Func <Brand, bool> > filter) { using (RentACarContext context = new RentACarContext()) { return(context.Set <Brand>().SingleOrDefault(filter)); } }
public Color Get(Expression <Func <Color, bool> > filter) { using (RentACarContext context = new RentACarContext()) //using içerisine yazılan kodlar bellekten işi bitince atılır, bu yüzden daha performanslı oluyor { return(context.Set <Color>().SingleOrDefault(filter)); } }
public List <Car> GetAll(Expression <Func <Car, bool> > filter = null) { using (RentACarContext context = new RentACarContext()) { return(filter == null?context.Set <Car>().ToList() : context.Set <Car>().Where(filter).ToList()); } }
public Color Get(Expression <Func <Color, bool> > filter) { using (RentACarContext context = new RentACarContext()) { return(context.Set <Color>().SingleOrDefault(filter)); } }
public List <Color> GetAll(Expression <Func <Color, bool> > filter = null) { using (RentACarContext context = new RentACarContext()) { return(filter != null?context.Set <Color>().Where(filter).ToList() : context.Set <Color>().ToList()); // ? -> eğer filter null ise ilk kısmı yani tümünü getirir değilse diğer kısmı getirir } }
public Brand Get(Expression <Func <Brand, bool> > filter) { //tek data getirecek using (RentACarContext context = new RentACarContext()) // IDisposable pattern implementation of c#. using ile daha performanslı. iş bitince garbage collector siler. { return(context.Set <Brand>().SingleOrDefault(filter)); } }
public void Delete(Brand entity) { using (RentACarContext context = new RentACarContext()) // IDisposable pattern implementation of c#. using ile daha performanslı. iş bitince garbage collector siler. { var deletedEntity = context.Entry(entity); //referansı yakala deletedEntity.State = EntityState.Deleted; //bu aslında silinecek bir nesne context.SaveChanges(); //ve şimdi sil } }
public void Update(Car entity) { using (RentACarContext context = new RentACarContext()) // IDisposable pattern implementation of c#. using ile daha performanslı. iş bitince garbage collector siler. { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
public void Add(Car entity) { using (RentACarContext context = new RentACarContext()) // IDisposable pattern implementation of c#. using ile daha performanslı. iş bitince garbage collector siler. { var addedEntity = context.Entry(entity); //referansı yakala addedEntity.State = EntityState.Added; //bu aslında eklenecek bir nesne context.SaveChanges(); //ve şimdi ekle } }
public void Delete(Color entity) { using (RentACarContext context = new RentACarContext()) { var deletedEntity = context.Entry(entity); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(Color entity) { using (RentACarContext context = new RentACarContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }
public void Update(Brand entity) { using (RentACarContext context = new RentACarContext()) { var updatedEntity = context.Entry(entity); //referansı yakala,veri kaynağıyla ilişkilendir updatedEntity.State = EntityState.Modified; // o aslında güncellenecek bir nesne context.SaveChanges(); } }
public void Delete(Brand entity) { using (RentACarContext context = new RentACarContext()) { var deletedEntity = context.Entry(entity); //referansı yakala,veri kaynağıyla ilişkilendir deletedEntity.State = EntityState.Deleted; // o aslında silinecek bir nesne context.SaveChanges(); } }
public void Remove(Brand entity) { using (RentACarContext context = new RentACarContext()) { var removeEntity = context.Entry(entity); removeEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(Brand entity) { using (RentACarContext context = new RentACarContext()) { var addedBrand = context.Entry(entity); addedBrand.State = EntityState.Added; context.SaveChanges(); } }
public void Remove(Car entity) { using (RentACarContext context = new RentACarContext()) { var RemoveEntity = context.Entry(entity); RemoveEntity.State = Microsoft.EntityFrameworkCore.EntityState.Deleted; context.SaveChanges(); } }
public void Modify(Car entity) { using (RentACarContext context = new RentACarContext()) { var ModifyEntity = context.Entry(entity); ModifyEntity.State = Microsoft.EntityFrameworkCore.EntityState.Modified; context.SaveChanges(); } }
public void Add(Car entity) { using (RentACarContext context = new RentACarContext()) { var addEntity = context.Entry(entity); addEntity.State = Microsoft.EntityFrameworkCore.EntityState.Added; context.SaveChanges(); } }
public void Update(Brand entity) { using (RentACarContext context = new RentACarContext()) { var updatedEntity = context.Entry(entity); updatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
//NuGet public void Add(Car entity) { //IDisposable pattern implementation of C# using (RentACarContext context = new RentACarContext()) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } }
public void Add(Car entity) { using (RentACarContext context = new RentACarContext()) { if (entity.DailyPrice >= 0 && entity.Descriptions.Length >= 2) { var addedEntity = context.Entry(entity); addedEntity.State = EntityState.Added; context.SaveChanges(); } else { Console.WriteLine("Hatalı giriş yapıldı lütfen kontrol ediniz!"); } } }