public IQueryable <Category> GetCategories() { var _db = new ShoppingCart.Models.ProductContext(); IQueryable <Category> query = _db.categories; return(query); }
public void Dispose() { if (_db != null) { _db.Dispose(); _db = null; } }
public IQueryable <Product> GetProducts([QueryString("id")] int?categoryId) { var _db = new ShoppingCart.Models.ProductContext(); IQueryable <Product> query = _db.products; if (categoryId.HasValue && categoryId > 0) { query = query.Where(p => p.CategoryID == categoryId); } return(query); }
public IQueryable <Product> GetProducts( [QueryString("id")] int?categoryId, [RouteData] string categoryName) { var _db = new ShoppingCart.Models.ProductContext(); IQueryable <Product> query = _db.Products; if (categoryId.HasValue && categoryId > 0) { query = query.Where(p => p.CategoryID == categoryId); } if (!String.IsNullOrEmpty(categoryName)) { query = query.Where(p => String.Compare(p.Category.CategoryName, categoryName) == 0); } return(query); }
public IQueryable <Product> GetProduct( [QueryString("ProductID")] int?productId, [RouteData] string productName) { var _db = new ShoppingCart.Models.ProductContext(); IQueryable <Product> query = _db.Products; if (productId.HasValue && productId > 0) { query = query.Where(p => p.ProductID == productId); } else if (!String.IsNullOrEmpty(productName)) { query = query.Where(p => String.Compare(p.ProductName, productName) == 0); } else { query = null; } return(query); }