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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:33:10+00:00 2026-06-09T01:33:10+00:00

I just finished reading Mike’s awesome tutorial over at: http://www.mikesdotnetting.com/Article/150/Web-Pages-Efficient-Paging-Without-The-WebGrid and I am using

  • 0

I just finished reading Mike’s awesome tutorial over at: http://www.mikesdotnetting.com/Article/150/Web-Pages-Efficient-Paging-Without-The-WebGrid

and I am using SQL CE 4.0 with Entity F/W ADO.NET and my search query is:

foreach(string term in query)
{
        var products = database.Products.Where(p =>
                p.PartNumber.ToLower().Contains(term.ToLower()) ||
                p.PartNumber.ToLower() == term.ToLower() || p.OProductName.ToLower().Contains(term.ToLower()) || p.OProductName.ToLower() == term.ToLower());
}

In Mike’s search query:

sql = "Select Title, ISBN, Description, FirstName, LastName, Category From Books " + 
           "Inner Join Authors on Books.AuthorId = Authors.AuthorId " + 
           "Inner Join Categories on Books.CategoryId = Categories.CategoryId " +
           "Order By BookId OFFSET @0 ROWS FETCH NEXT @1 ROWS  ONLY;";

var result = db.Query(sql, offset, pageSize);

He uses the normal “WebMatrix way” of performing select query with database.

The part that has me stuck, is how to I write his OFFSET @0 ROWS FETCH NEXT @1 ROWS ONLY; in my version of the query? How do I write it in EF ado.net?

I hope this makes sense.

  • 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-09T01:33:12+00:00Added an answer on June 9, 2026 at 1:33 am

    What you are looking for are the LINQ methods Skip() and Take(). Skip() lets you skip records – the OFFSET @0 ROWS portion of the query. Take() lets you specify how many rows to return – the FETCH NEXT @1 ROWS ONLY portion of the query.

    So your code to return PageSize items from page Page, might look something like this:

        var products = database.Products.Where(p =>
                p.PartNumber.ToLower().Contains(term.ToLower()) ||
                p.PartNumber.ToLower() == term.ToLower() || p.OProductName.ToLower().Contains(term.ToLower()) || p.OProductName.ToLower() == term.ToLower())
                .OrderBy(p => p.PartNumber)
                .Skip((Page - 1) * PageSize).Take(PageSize);
    

    Edit: You’ll also need to throw in an OrderBy() before the Skip(), as only ordered queries can be skipped. So you might want to order by part number, for example.

    As an aside, it’s a good thing you are using SQL CE 4.0, as previous versions did not support Skip() in EF!!

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

Sidebar

Related Questions

Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
I just finished reading Restful Web Services and Nobody Understands REST or HTTP and
Just finished reading Jon Skeet's article about events and delegates and got a question.
I just finished reading this post: https://developer.yahoo.com/performance/rules.html#flush and have already implemented a flush after
I just finished reading this article on the advantages and disadvantages of exceptions and
I have just finished reading an article on MSDN by John Evdemon . He
I just finished reading the HTML5 Developer's Cookbook and have a question. I've read
I just finished reading about scoping in the R intro , and am very
I just finished looking at this question: https://stackoverflow.com/questions/753122/which-cloud-computing-platform-should-i-choose But, I am not certain what
I just finished setting up my Eclipse with the Android plug-in. (i.e https://dl-ssl.google.com/android/eclipse/ )

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.