コード例 #1
0
ファイル: Site.Master.cs プロジェクト: chinh2509/chinh2509
        public IQueryable <Category> GetCategories()
        {
            var _db = new Lab02.Models.BookContext();
            IQueryable <Category> query = _db.Categories;

            return(query);
        }
コード例 #2
0
        public IQueryable <Book> GetBooks([QueryString("id")] int?categoryId)
        {
            var _db = new Lab02.Models.BookContext();
            IQueryable <Book> query = _db.Books;

            if (categoryId.HasValue && categoryId > 0)
            {
                query = query.Where(p => p.CategoryID == categoryId);
            }
            return(query);
        }
コード例 #3
0
        public IQueryable <Book> GetBook([QueryString("bookID")] int?bookId)
        {
            var _db = new Lab02.Models.BookContext();
            IQueryable <Book> query = _db.Books;

            if (bookId.HasValue && bookId > 0)
            {
                query = query.Where(p => p.BookID == bookId);
            }
            else
            {
                query = null;
            }
            return(query);
        }