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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:08:16+00:00 2026-05-19T22:08:16+00:00

Say i want to add pagination support. My app is separated in Web, Services

  • 0

Say i want to add pagination support.
My app is separated in Web, Services and repositories.

The Controller only speaks to the Service and the Service gets Data and does business logic.

Say i want pagination support.. I have this method in my ContributorService

public IQueryable<Contributor> GetContributors(int page, int pageSize)
        {
            return _repository.GetAll().OrderBy(c=>c.ACC_CREATEDATE).Skip((page)*pageSize).Take(pageSize);//solo temporalmente
        }

is that ok?? or should the OrderBy, Skip, Take be done in the repository?

which currently only does this

public IQueryable<Contributor> GetAll()
        {
            return db.Contributors;
        }
  • 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-19T22:08:16+00:00Added an answer on May 19, 2026 at 10:08 pm

    I would add the query to the business object ( I think you dont have one, do you), there you may have a base version of it, and another one for the paged data. And would expect to service to execute that query by calling the ToList, I find it dangerous to return a query object to the controller.

    Your repository might have a GetPartial Method, with the sort, from, to, and a filter params. If you have a generic service, you might also implement this in that generic service.

    public List<Contributor> GetPartial<TSortBy>(Expression<Func<Contributor, TSortBy>> sortByExpr, Expression<Func<Contributor, bool>> filterExpr, int pageNo, int pageSize)
            {
                var query = db.Contributors;
                if (filterExpr != null)
                       query.Where(filterExpr);
    query.orderBy(sortByExpr).Skip (...).Take(...).ToList();
    
            }
    

    if you have a Repository class, you can add this method.
    By the way, I am using Dynamic LINQ, which makes it easier to pass order by expression as plain text (just like sql)

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

Sidebar

Related Questions

Lets say I wan't to add 1 to an integer. This will only be
Let's say I want to add a list of strings or just one to
I have an app with support for several different languages. Now lets say I
i want to add div base on input attr title, i mean to say
How to model hierarchical relationship in rest api? Let's say I want to add
Say I want to add a value to an array, but it doesn't matter
This is embarrassing, but: Let say I want to add 1 to x until
Say I want to add a background image to something, I might write: background:
Lets say I want to add an extension method to class B. Can I
Let's say I want to add some new features to Rails. According to the

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.