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 8793981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:11:31+00:00 2026-06-13T23:11:31+00:00

As per the profiler below, even with lazy loading being disabled, my query is

  • 0

As per the profiler below, even with lazy loading being disabled, my query is taking a long time to return results:

enter image description here

Here s my query:

enter image description here

Here is my repository, where I am doing something ridiculous, taking only ONE record:

enter image description here


Questions:


  1. Could someone tell me what would be the correct procedure to take say, 100 records and return them as fast as possible so the user will not have to wait long (while using the Unit of Work / Repository pattern)?

  2. How would EF know how to paginate this info to a grid so the next batch of 100 records are available to the user, and the next batch, and so on?

I do not understand if I have .Take(1) why is the profiler returning 73,722 rows?

  • 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-13T23:11:31+00:00Added an answer on June 13, 2026 at 11:11 pm

    Your dbSet.ToList() is causing the LINQ-to-Entities query to execute (and it says “please load the whole table from the database into memory”), not your Take(1). This is applied to the already loaded result, not to the database query.

    You just need to change the order:

    dbSet.Take(1).ToList()
    

    This would query for only one element in the database (using TOP 1 in SQL). To get the next records for paging you can use Skip (together with Take), for example:

    public IEnumerable<T> GetPage(int pageNumber, int entitiesPerPage)
    {
        return dbSet
            .Skip((pageNumber - 1) * entitiesPerPage)
            .Take(entitiesPerPage)
            .ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Per the code below, I am getting the following message. I am fairly certain
Here is an output of Compute Visual Profiler for my kernel on GT 440:
Per a client's request I have written a communication class that inherits from webclient.
Per a great answer from another question I have begun mounting global resources (css/js/images)
Per this question (see comments near the bottom), I was wondering if anyone knows
Per the documentation , String.Format will throw a FormatException if either (A) the format
As per [http://lessons.goxtk.com/09/][1] [1]: http://lessons.goxtk.com/09/ i need to use a .vtk file with 15,000
As per question says. Specifically i want the html.beginform() to have the runat=server attribute.
As per http://www.w3schools.com/cssref/sel_last-child.asp When i am trying to apply :last-child for my code, the
As per Scott Meyers, to prevent repetition of code in the const version of

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.