public List <Car> GetAll(Expression <Func <Car, bool> > filter = null) { using (CarRentalContext context = new CarRentalContext()) { return(filter == null?context.Set <Car>().ToList() : context.Set <Car>().Where(filter).ToList()); } }
public List <Car> GetCarsByColorId(int id) { using (CarRentalContext context = new CarRentalContext()) { return(context.Set <Car>().Where(p => p.ColorId == id).ToList()); } }
public Car Get(Expression <Func <Car, bool> > filter) { using (CarRentalContext context = new CarRentalContext()) { return(context.Set <Car>().SingleOrDefault(filter)); } }
// public async Task Add(T entity) // { // // return await _context.Set<T>().AddAsync(entity); // await _context.AddAsync(entity); // } public async Task <IEnumerable <T> > Get() { var items = await _context.Set <T>().ToListAsync(); return(items); }
public BaseRepository(CarRentalContext context) { this.context = context; this.dbSet = context.Set <TEntity>(); }
public void Delete(TEntity entity) { _carRentalContext.Set <TEntity>().Remove(entity); }