예제 #1
0
 public IEnumerable <T> GetAll(Expression <Func <T, bool> > filter)
 {
     using (var context = new ShopContext())
     {
         if (filter == null)
         {
             return(context.Set <T>().ToList());
         }
         else
         {
             return(context.Set <T>().Where(filter).ToList());
         }
     }
 }
예제 #2
0
 public T GetById(int id)
 {
     using (var context = new ShopContext())
     {
         return(context.Set <T>().Find(id));
     }
 }
예제 #3
0
 public T GetOne(Expression <Func <T, bool> > filter)
 {
     using var context = new ShopContext();
     return(context.Set <T>().SingleOrDefault());
 }