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