Exemplo n.º 1
0
 public List <Car> GetAll(Expression <Func <Car, bool> > filter = null)
 {
     using (MyDatabaseContext context = new MyDatabaseContext())
     {
         return(filter == null
             ? context.Set <Car>().ToList()
             : context.Set <Car>().Where(filter).ToList());
     }
 }
Exemplo n.º 2
0
 public List <Color> GetAll(Expression <Func <Color, bool> > filter = null)
 {
     using (MyDatabaseContext context = new MyDatabaseContext())
     {
         return(filter == null                                //Filtre null mı ?
             ? context.Set <Color>().ToList()                 //Evetse bura çalışır
             : context.Set <Color>().Where(filter).ToList()); //Değilse bura çalışır
     }
 }
Exemplo n.º 3
0
 public Color GetById(Expression <Func <Color, bool> > filter)
 {
     using (MyDatabaseContext context = new MyDatabaseContext())
     {
         return(context.Set <Color>().SingleOrDefault(filter));
     }
 }
Exemplo n.º 4
0
 public Brand Get(Expression <Func <Brand, bool> > filter)
 {
     using (MyDatabaseContext context = new MyDatabaseContext())
     {
         return(context.Set <Brand>().SingleOrDefault(filter));
     }
 }