public List <Product> GetByUnitPrice(decimal min, decimal max) { using (EtradeContext context = new EtradeContext()) { return(context.Product.Where(p => p.UnitPrice >= min && p.UnitPrice <= max).ToList()); } }
public List <Product> GetByname(String key) { using (EtradeContext context = new EtradeContext()) { return(context.Product.Where(p => p.Name.Contains(key)).ToList()); } }
public List <Product> GetAll() { using (EtradeContext context = new EtradeContext()) { return(context.Product.ToList()); } }
public void Add(Product product) { using (EtradeContext context = new EtradeContext()) { context.Product.Add(product); context.SaveChanges(); } }
public Product GetById(int id) { using (EtradeContext context = new EtradeContext()) { var result = context.Product.FirstOrDefault(p => p.Id == id); return(result); } }
public void Delete(Product product) { using (EtradeContext context = new EtradeContext()) { var entity = context.Entry(product); entity.State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } }