public Car GetById(Expression <Func <Car, bool> > filter) { using (RentContext context = new RentContext()) { return(context.Set <Car>().SingleOrDefault(filter)); } }
public List <Car> GetAll(Expression <Func <Car, bool> > filter = null) { using (RentContext context = new RentContext()) { return(filter == null?context.Set <Car>().ToList() : context.Set <Car>().Where(filter).ToList()); } }
public void Update(Car entity) { using (RentContext context = new RentContext()) { var updatedContext = context.Entry(entity); updatedContext.State = EntityState.Modified; context.SaveChanges(); } }
public void Delete(Car entity) { using (RentContext context = new RentContext()) { var deletedContext = context.Entry(entity); deletedContext.State = EntityState.Deleted; context.SaveChanges(); } }
public void Add(Car entity) { using (RentContext context = new RentContext()) { var addedContext = context.Entry(entity); addedContext.State = EntityState.Added; context.SaveChanges(); } }