Beispiel #1
0
 public List <Brand> GetAll(Expression <Func <Brand, bool> > filter = null)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         return(filter == null?context.Set <Brand>().ToList() : context.Set <Brand>().Where(filter).ToList());
     }
 }
Beispiel #2
0
 public IList <Car> GetAll(Expression <Func <Car, bool> > filter = null)
 {
     //IDisposible pattern implementation of c#
     using (CarRentalContext context = new CarRentalContext())
     {
         return(filter == null
             ? context.Set <Car>().ToList()
             : context.Set <Car>().Where(filter).ToList());
     }
 }
Beispiel #3
0
 public Brand Get(Expression <Func <Brand, bool> > filter)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         return(context.Set <Brand>().SingleOrDefault(filter));
     }
 }
 public Color Get(Expression <Func <Color, bool> > filter)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         return(context.Set <Color>().SingleOrDefault(filter));
     }
 }
Beispiel #5
0
 public List <Car> GetCarsByColorsId(int colorsId)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         return(context.Set <Car>().Where(a => a.ColorId == colorsId).ToList());
     }
 }
Beispiel #6
0
 public List <Car> GetCarsByBrandId(int brandId)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         return(context.Set <Car>().Where(a => a.BrandId == brandId).ToList());
     }
 }
Beispiel #7
0
        public Car GET(Expression<Func<Car, bool>> filter)
        {
            using (CarRentalContext context = new CarRentalContext())
            {

                return context.Set<Car>().SingleOrDefault(filter);

            }
        }