public Product Get(Expression <Func <Product, bool> > predicate = null)
 {
     using (var _context = new MAppDataContext())
     {
         return(_context.Set <Product>().Include(s => s.Category).FirstOrDefault(predicate));
     }
 }
 public bool Exist(Expression <Func <Product, bool> > predicate)
 {
     using (var _context = new MAppDataContext())
     {
         return(_context.Set <Product>().Any(predicate));
     }
 }
 public void DeleteMultiple(List <Product> entityList)
 {
     using (var _context = new MAppDataContext())
     {
         _context.Set <Product>().RemoveRange(entityList);
         _context.SaveChanges();
     }
 }
 public void Update(Product entity)
 {
     using (var _context = new MAppDataContext())
     {
         var updatedEntity = _context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         _context.SaveChanges();
     }
 }
 public void Delete(Product entity)
 {
     using (var _context = new MAppDataContext())
     {
         var deleteEntity = _context.Entry(entity);
         deleteEntity.State = EntityState.Deleted;
         _context.SaveChanges();
     }
 }
 public void Add(Product entity)
 {
     using (var _context = new MAppDataContext())
     {
         var addEntity = _context.Entry(entity);
         addEntity.State = EntityState.Added;
         _context.SaveChanges();
     }
 }
 public List <Product> GetAsQueryable(Expression <Func <Product, bool> > predicate = null)
 {
     using (var _context = new MAppDataContext())
     {
         if (predicate == null)
         {
             return(_context.Set <Product>().Include(s => s.Category).ToList());
         }
         else
         {
             return(_context.Set <Product>().Include(s => s.Category).Where(predicate).ToList());
         }
     }
 }