コード例 #1
0
        public IQueryable <Category> GetCategories()
        {
            var _db = new Display_Data.Models.ProductContext();
            IQueryable <Category> query = _db.Categories;

            return(query);
        }
コード例 #2
0
        public IQueryable <Product> GetProducts([QueryString("id")] int?categoryId)
        {
            var _db = new Display_Data.Models.ProductContext();
            IQueryable <Product> query = _db.Products;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(p => p.CategoryID == categoryId);
            }
            return(query);
        }