Beispiel #1
0
        public IQueryable <Category> GetCategories()
        {
            var _db = new Lab02.Models.BookContext();
            IQueryable <Category> query = _db.Categories;

            return(query);
        }
Beispiel #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);
        }
        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);
        }