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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:41:45+00:00 2026-05-13T19:41:45+00:00

I have the following code: int pageNumber = 0; int pageCount = 10; int

  • 0

I have the following code:

int pageNumber = 0;
int pageCount = 10;
int numberOfRecords = 10;

    var query = V_ers_notice.Skip(pageNumber * pageCount).Take(numberOfRecords );

return query.OrderByDescending(id => id.DOC_DATE).Select(ERSNoticeMap.DataToObject).ToList());

The ERSNoticeMap code is as follows:

public class ERSNoticeMap
{
        public static readonly Func<V_ers_notice, OGeneralFile> DataToObject = mapper =>
                                          new OGeneralFile
                                          {
                                              Docket = mapper.DOCKET,
                                              DocumentDate = mapper.DOC_DATE,
                                              FiledDate = mapper.FILED_DATE,
                                              FileGuid = mapper.FGUID,
                                              FileName = mapper.FName,
                                              FilePath = mapper.FPathName,
                                              FileSize = mapper.FSize,
                                              FileType = mapper.FType,
                                              Issuance = mapper.ISSUANCE,
                                              Title = mapper.TITLE,
                                              FileId = mapper.FID,
                                          };
}

And my OGeneralFile is as follows (even though it has nothing to do with this problem):

public class OGeneralFile
    {
        public int FileId { get; set; }
        public Guid FileGuid { get; set; }
        public string FilePath { get; set; }
        public string FileName { get; set; }
        public string FileType { get; set; }
        public string FileSize { get; set; }
        public string Issuance { get; set; }
        public DateTime? DocumentDate { get; set; }
        public DateTime? FiledDate { get; set; }
        public string Docket { get; set; }
        public string Title { get; set; }
        public string Type { get; set; }
    }

Now, here is the strange part. When I run this and look at SQL profiler, it is not ordering my query properly. I get the following:

SELECT [t1].[fID] AS [FID], [t1].[fGUID] AS [FGUID], [t1].[fPathName] AS [FPathName], [t1].[fName] AS [FName], [t1].[fType] AS [FType], [t1].[fSize] AS [FSize], [t1].[ISSUANCE], [t1].[DOC_DATE], [t1].[FILED_DATE], [t1].[DOCKET], [t1].[TITLE]
FROM (
    SELECT TOP (10) [t0].[fID], [t0].[fGUID], [t0].[fPathName], [t0].[fName], [t0].[fType], [t0].[fSize], [t0].[ISSUANCE], [t0].[DOC_DATE], [t0].[FILED_DATE], [t0].[DOCKET], [t0].[TITLE]
    FROM [v_ers_notice] AS [t0]
    ) AS [t1]
ORDER BY [t1].[DOC_DATE] DESC

The order by should be in the inner query when selecting the top 10 not on the outside.

Any thoughts to why this may be happening?

Thanks,

  • 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-05-13T19:41:45+00:00Added an answer on May 13, 2026 at 7:41 pm

    I think your query is wrong. You need to OrderBy before you do skip and take, not after:

    var query = V_ers_notice.OrderByDescending(id => id.DOC_DATE)
                            .Skip(pageNumber * pageCount)
                            .Take(numberOfRecords );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my controller: public ActionResult Details(int id) { var
So...I have the following code: int main(void) { const char *s=hello, world; cout<<&s[7]<<endl; return
I have following code int i; //gobal var Thread1: { ... i=some value; }
I have the following code: int main() { // Variables char name; // Take
I have the following c++ code int factorial(int n){ if(n==0){ return 1; } return
I have the following code int ParseData(unsigned char *packet, int len) { struct ethhdr
I have the following code int main() { int a=6; void *p; p=&a; p++;
If I have the following Java code: int[][] readAPuzzle() { Scanner input = new
Let's say we have the following c++ code: int var1; __asm { mov var1,
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int

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.