Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:20:40+00:00 2026-06-09T22:20:40+00:00

There is a book management system web application based on ASP.NET MVC3. When click

  • 0

There is a book management system web application based on ASP.NET MVC3. When click the book index page, data query is very slow and user has to wait for several seconds for response. The code of Action Index in BookController below:

    public ViewResult Index(string sortOrder, int? page)
    {
        ViewBag.NameSortParam = string.IsNullOrEmpty(sortOrder) ? "desc" : "";
        ViewBag.CurrentSort = sortOrder;

        BookModel books = from b in db.Books select b; // db = new BookContext();
        switch (sortOrder) {
            case "desc":
                books = books.OrderByDescending(b => b.Name);
                break;
            default:
                books = books.OrderBy(b => b.Name);
                break;
        }
        int pageSize = 15;
        int pageNumber = (page ?? 1);

        return View(books.ToPagedList(pageNumber, pageSize));
    }

In my opinion, the main reason of slow is that server does not response to client until all data are ready. This process takes much time.

I do not know how to solve this problem, is there any method to improve data query performance in this case? Thank you!

update:
backend database is SQL Server Compact Edition 4.0

UPDATE
I update my logic code below, orderby is used before skip and take statements. Everything goes well. Thank you all for help.

books = (from b in db.Books
                       orderby b.Name descending
                       select b)
                       .Skip((page - 1) * pageSize)
                       .Take(pageSize)
                       .ToList();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:20:41+00:00Added an answer on June 9, 2026 at 10:20 pm

    You are loading in all your books before filtering the dataset to just the data you need (by using ToPagedList). Change your query and use the Skip and Take methods instead of ToPagedList.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen Books on ASP.Net, VB.Net, etc... Is there any book on .NET
There's an open book quiz for a job application I'm doing, and it's obviously
How do I create a database management system from scratch? Are there any books,
I am working on a content management system to fit inside my small application.
I am following Gorman's virtual memory management book. There is a section about kernel
On page 13 in the GoF book there is a statement: Two objects of
Is there a book explaining the design of FAT32, NTFS, ReiserFS, ext2, ext3, ext4,
Is there any book or links that I can read some tutorial about the
I'm reading a book about SQL. In that book there's the term Ad Hoc
I'm trying to work my way through an Objective-C tutorial. In the book there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.