Sorting/Filtering MVC

后端 未结 1 409
情书的邮戳
情书的邮戳 2021-01-27 00:08

I am trying to sort my search results by author last name, publication date (newest and oldest), title, most popular, and highest rated!

I used a n example and almost co

相关标签:
1条回答
  • 2021-01-27 00:40

    Your Index() is just returning the unsorted collection (after getting the collection and then sorting it, you toss it away and call the database again using return View(db.Books.ToList()); which returns an unsorted collection.

    Change the last line of your code to

    return View(books);
    
    0 讨论(0)
提交回复
热议问题