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()); } } }
public T GetById(int id) { using (var context = new ShopContext()) { return(context.Set <T>().Find(id)); } }
public T GetOne(Expression <Func <T, bool> > filter) { using var context = new ShopContext(); return(context.Set <T>().SingleOrDefault()); }