Exemple #1
0
        private static void DeletingAndUpdatingCars(CarDbContext db)
        {
            var cars = db.Cars.Where(c => c.Price > 15000).ToList();

            db.RemoveRange(cars);
            // this make query for every car
            //  db.SaveChanges(); - even without Savechanges

            var cars2 = db.Cars
                        .Where(c => c.Price > 15000);
            /* .Delete();*/ // using Z.EntityFramework.Plus  optimize the delete query

            var cars3 = db.Cars.Where(c => c.Price < 20000);
            //.Update(c => new Car { Price = c.Price * 1.2M });
        }