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

            return(query);
        }
コード例 #2
0
ファイル: FoodList.aspx.cs プロジェクト: aman1908/Foodie
        public IQueryable <Food> GetFoods([QueryString("id")] int?categoryId)
        {
            var _db = new Foodie.Models.FoodContext();
            IQueryable <Food> query = _db.Foods;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(f => f.CategoryID == categoryId);
            }
            return(query);
        }
コード例 #3
0
        public IQueryable <Food> GetFood([QueryString("foodID")] int?foodId)
        {
            var _db = new Foodie.Models.FoodContext();
            IQueryable <Food> query = _db.Foods;

            if (foodId.HasValue && foodId > 0)
            {
                query = query.Where(f => f.FoodID == foodId);
            }
            else
            {
                query = null;
            }
            return(query);
        }