コード例 #1
0
 public Product GetById(int id)
 {
     using (EtradeContext context = new EtradeContext())
     {
         return(context.Products.FirstOrDefault(p => p.Id == id));
     }
 }
コード例 #2
0
 public List <Product> ikiFiyatGetir(decimal min, decimal max)
 {
     using (EtradeContext context = new EtradeContext())
     {
         return(context.Products.Where(p => p.UnitPrice >= min && p.UnitPrice <= max).ToList());
     }
 }
コード例 #3
0
 public List <Product> GetByName(string key)
 {
     using (EtradeContext context = new EtradeContext())
     {
         return(context.Products.Where(p => p.Name.Contains(key)).ToList());
     }
 }
コード例 #4
0
 public List <Product> GetAll()
 {
     using (EtradeContext context = new EtradeContext())
     {
         return(context.Products.ToList());
     }
 }
コード例 #5
0
 public void Sil(Product product)
 {
     using (EtradeContext context = new EtradeContext())
     {
         var entity = context.Entry(product);
         entity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
コード例 #6
0
 public void Guncelle(Product product)
 {
     using (EtradeContext context = new EtradeContext())
     {
         var entity = context.Entry(product);
         entity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }