예제 #1
0
 public List <Product> GetAll(Expression <Func <Product, bool> > filter = null)
 {
     using (CarRentalDataBaseContext context = new CarRentalDataBaseContext())
     {
         return(filter == null?context.Set <Product>().ToList()
                    : context.Set <Product>().Where(filter).ToList());
     }
 }
예제 #2
0
 public Product Get(Expression <Func <Product, bool> > filter)
 {
     using (CarRentalDataBaseContext context = new CarRentalDataBaseContext())
     {
         return(context.Set <Product>().SingleOrDefault(filter));
     }
 }