Beispiel #1
0
 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());
     }
 }
Beispiel #2
0
 public List <Car> GetCarsByColorId(int id)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         return(context.Set <Car>().Where(p => p.ColorId == id).ToList());
     }
 }
Beispiel #3
0
 public Car Get(Expression <Func <Car, bool> > filter)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         return(context.Set <Car>().SingleOrDefault(filter));
     }
 }
Beispiel #4
0
        // 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);
        }
Beispiel #5
0
 public BaseRepository(CarRentalContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
Beispiel #6
0
 public void Delete(TEntity entity)
 {
     _carRentalContext.Set <TEntity>().Remove(entity);
 }