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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:58:28+00:00 2026-05-28T18:58:28+00:00

I am using entity framework with several layers (SOA architecture). I was wondering where

  • 0

I am using entity framework with several layers (SOA architecture). I was wondering where it is best to do the ordering of a list or IEnumerable.. would it be on the persistence layer from the repositories ? would it be on the service layer ? or would it be on the presentation layer ? (in controllers)

And why?

  • 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-28T18:58:30+00:00Added an answer on May 28, 2026 at 6:58 pm

    While it is certainly possible to sort a list at any layer you have to bear in mind the implications of your choice.

    If you are dealing with a large data set, you may want to sort it at database level (for performance reasons). If the data set is small, this is not an issue.

    If you perform sorting at the data access layer: you have to either pass sort options to your GetList methods or subject all method callers to the same sort order.

    I view sort order as more of a UI concern and this is best handled in the presentation layer (in your case a controller action).


    Update in response to @Rushino comment:
    If you are doing pagination at database level then you have no choice but to sort at database level.


    Update 2
    Here is why you need to sort at database level when you are doing pagination at database level. I will demonstrate with an example:
    Given sample data:

    3
    2
    6
    4
    5
    1

    Scenario 1: Pagination in the database, sorting in the data layer

    When you request page 1 (with page size of 3) database will return:

    3
    2
    6

    Data layer will then sort this and return:

    2
    3
    6

    Scenario 2: Sorting and pagination both in the database

    When you request page 1 (with page size of 3) database will sort first:

    1
    2
    3
    4
    5
    6

    Then return page 1 to data layer:

    1
    2
    3

    As you can see, the reason for sorting within database when doing pagination is not because of the amount of data. It is because this is the only way to get correct results.

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

Sidebar

Related Questions

I'm using Entity Framework for creation of my Data Access Layer and I want
In my application I'm using Entity Framework 4.0 Model First. I have several tables
I'm using FluentValidation framework. And at the moment I have several validators (per entity).
We have an Entity Framework project with several models set up using .NET 4
Using Entity Framework, I suddenly get this strange error after publishing my asp.net mvc
I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes
I am using Entity Framework with my website. To improve performance, I have started
I'm currently using Entity Framework and am running into this issue: The relationship between
I'm using Entity Framework in my project, and I have the problem that, once
I am using Entity Framework 4 in a desktop application with SQL Compact. I

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.