示例#1
0
 public void Delete(Car entity)
 {
     using (CarRentalDBContext context = new CarRentalDBContext())
     {
         var deletedCar = context.Entry(entity);
         deletedCar.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
示例#2
0
 public void Update(Car entity)
 {
     using (CarRentalDBContext context = new CarRentalDBContext())
     {
         var updatedCar = context.Entry(entity);
         updatedCar.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#3
0
 public void Add(Car entity)
 {
     using (CarRentalDBContext context = new CarRentalDBContext())
     {
         var addedCar = context.Entry(entity);
         addedCar.State = EntityState.Added;
         context.SaveChanges();
     }
 }