public IQueryable <Models.hang> GetBooks([QueryString("id")] int?categoryId) { var _db = new BooksShopOnline.Models.Context(); IQueryable <Models.hang> query = _db.Books; if (categoryId.HasValue && categoryId > 0) { query = query.Where(p => p.CategoryID == categoryId); } return(query); }
public IQueryable <Models.hang> GetDetails([QueryString("bookID")] int?bookId) { var _db = new BooksShopOnline.Models.Context(); IQueryable <Models.hang> query = _db.Books; if (bookId.HasValue && bookId > 0) { query = query.Where(p => p.BookID == bookId); } else { query = null; } return(query); }