public List <Product> GetUnitePrice(decimal price)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         return(context.Products.Where(x => x.UnitPrice >= price).ToList());
     }
 }
 public List <Product> GetAll(Expression <Func <Product, bool> > filter = null)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         return(context.Products.ToList());
     }
 }
 public List <Product> GetAll()
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         return(context.Products.ToList());
     }
 }
 public List <Product> GetUnitePrice(decimal max, decimal min)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         return(context.Products.Where(x => x.UnitPrice >= min && x.UnitPrice < max).ToList());
         //where ile direkt tablodan koşul ile veri alabiliyoruz
     }
 }
 public void Delete(Product products)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         var entity = context.Entry(products);
         entity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
 public Product GetByID(int id)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         return(context.Products.FirstOrDefault(x => x.ProductId == id));
         // return context.Products.SingleOrDefault(x => x.ID == id);
         //tabloda eğer gönderilen id varsa veri çek yoksa default null gönder firstordefault
         //tabloda eğer gönderilen id birden fazla ise sadece bir veriyi çek yoksa default null gönder singleordefault
     }
 }
 public void Add(Product products)
 {
     using (NorthWindContext context = new NorthWindContext())
     {
         //context.Products.Add(products);
         var entity = context.Entry(products);
         entity.State = EntityState.Added;
         context.SaveChanges();
     }
 }