public List <Car> GetAll(Expression <Func <Car, bool> > filter = null) { using (CarRentalDBContext context = new CarRentalDBContext()) { return(filter == null?context.Set <Car>().ToList() : context.Set <Car>().Where(filter).ToList()); // filter = holding lambda expressions while using Linq queries } }
public Car Get(Expression <Func <Car, bool> > filter = null) { using (CarRentalDBContext context = new CarRentalDBContext()) { return(context.Set <Car>().SingleOrDefault(filter)); } }