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

  • Home
  • SEARCH
  • 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 116095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:07:26+00:00 2026-05-11T03:07:26+00:00

Is there a limit to the rows that IEnumerable.Count() (or IQueryable.Count()) using LINQ to

  • 0

Is there a limit to the rows that IEnumerable.Count() (or IQueryable.Count()) using LINQ to SQL? For whatever reason, if my query returns more than 200 records, I only get 200 from IEnumerable.Count(). I’ve even tried using IEnumerable.LongCount() (even though the number of results shouldn’t be high enough to need it). I’ve also verified that calling COUNT on the database returns more than 200 records.

I’ve checked MSDN and tried Googling it, but to no avail.

Am I going crazy, or is there something that I’m missing somewhere? I suppose this isn’t really a big deal (as the program is inserting the right number of records), but it’d be nice to be able to log the number of records transferred.

Could we see some sample code?

public IEnumerable<Irms_tx_modify_profile_ban> ExtractNewAdmits()     {         var results = from a in _dc.Applications                       select (Irms_tx_modify_profile_ban)new RMSProfile                       {                           //assign column names to property names                       };          //Don't know why, but Bad Things happen if you don't put the         //OfType call here.         IEnumerable<Irms_tx_modify_profile_ban> narrowed_results = results.OfType<Irms_tx_modify_profile_ban>();         Program.log.InfoFormat('Read {0} records from Banner.', narrowed_results.Count());         return narrowed_results;       } 

The reason for the comment about bad things happening is due to the issues brought up in this thread. What I did just find out is that if I call Count on narrowed_results (IEnumerable), it returns the right amount. If I call it on results (IQueryable), it returns just 200. I’ll go ahead and solve Skeet’s answer (since he mentioned the difference between IQueryable and IEnumerable), but if anyone is able to explain why this is happening, I’d like to hear it.

  • 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. 2026-05-11T03:07:26+00:00Added an answer on May 11, 2026 at 3:07 am

    I’ve not heard of anything like that, and it does sound very odd.

    The most obvious thing to check is what query is being sent to the database. Also, it matters a great deal whether you’re calling Enumerable.Count() (i.e. on an IEnumerable<T>) or Queryable.Count() (i.e. on an IQueryable<T>). The former will be iterating through the actual rows in .NET code to retrieve the count; the latter will put the count into the query.

    Could we see some sample code?

    EDIT: Okay, so having seen the code:

    • When you didn’t call OfType, it was executing the count at the SQL level. That should have been visible in the SQL logged, and should be reproducible with any other SQL tool.

    • I suspect you didn’t really have to call OfType. You could have called AsEnumerable, or just declared results as IEnumerable<Irms_tx_modify_profile_ban>. The important thing is that the type of the variable decides the extension method to use – and thus where the count is executed.

    It’s worth noting that your current solution is really inefficient – it’s fetching all the data, and counting it but ignoring everything but the count. It would be much better to get the count onto the server side – and while I know that doesn’t work at the moment, I’m sure with a bit of analysis we can make it work 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 129k
  • Answers 129k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer After running profiling I'm seeing a lot of time spent… May 12, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer Turns out this is a CRM security setting that was… May 12, 2026 at 5:51 am
  • Editorial Team
    Editorial Team added an answer Use the usort function with this comparison function: function cmpByScore($a,… May 12, 2026 at 5:51 am

Related Questions

Is there a way to limit the number of rows in a SQL Server
MySQL ResultSets are by default retrieved completely from the server before any work can
Until Office 2007, Excel has a maximum of 65,000 rows. Office 2007 bumped that
How can I make an ORDER BY clause with a small LIMIT (ie 20

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.