Beispiel #1
0
 public Car Get(Expression <Func <Car, bool> > filter = null)
 {
     using (CarRentContext context = new CarRentContext())
     {
         return(context.Set <Car>().SingleOrDefault(filter));
     }
 }
Beispiel #2
0
 public void Update(Car entity)
 {
     using (CarRentContext context = new CarRentContext())
     {
         var updateEntity = context.Entry(entity);
         updateEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #3
0
 public List <Car> GetAll(Expression <Func <Car, bool> > filter = null)
 {
     using (CarRentContext context = new CarRentContext())
     {
         return(filter == null
             ? context.Set <Car>().ToList()
             : context.Set <Car>().Where(filter).ToList());
     }
 }
Beispiel #4
0
 public void Delete(Car entity)
 {
     using (CarRentContext context = new CarRentContext())
     {
         var deleteEntity = context.Entry(entity);
         deleteEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Beispiel #5
0
 public void Add(Car entity)
 {
     using (CarRentContext context = new CarRentContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }