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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:58:42+00:00 2026-05-30T03:58:42+00:00

If you have a business rule where the first 30 items in table will

  • 0

If you have a business rule where the first 30 items in table will never be seen by the user (or UI) should you put this filter in the Repository’s GetAll()? Meaning, would the repository handle filtering of data, molding of data to hand back to the caller like a ViewModel or Controller? I’ve heard that Models should be thick, and controllers/vms should be light.

The issue I’m running into is another developer who is sharing a project with me made all of his repositories (one per table) simply all use the same implementation that simply copies properties of a LinqToSql type to a domain type. There’s no logic in the repository itself other than updating and deleting or getting data by a Func supplied.

I on the other hand created a repository (that inherited from IRepository of T) for each table and put specific logic in some (not all) where I felt logic was needed to hand back the domain objects.

So in my case, business logic could be done in the repository, in his case it has to be done by the user which could be a service or the ViewModel directly. Which is more preferred?

  • 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-30T03:58:44+00:00Added an answer on May 30, 2026 at 3:58 am

    If you have a business rule where the first 30 items in table will never be seen by the user (or UI) should you put this filter in the Repository’s GetAll()?

    First of all this does not sound like a business rule. Business rules are expressed in ubiquitous language and this language does not have words like ‘table’ unless you are working on a database engine.

    Answering you main question, the filtering logic can absolutely live inside repository. This is what repository is for: encapsulate storage, retrieval and search. One of the most important things to understand about repository is that its interface belongs to domain layer, but its implementation belongs to data access layer. So in your case the code would look like this:

    Domain:

    // repository interface:
    public interface Orders{ 
       IList<Order> GetDelinquent();
    }
    

    Data access:

    public SqlOrders : Orders{ 
       IList<Order> GetDelinquent(){
          // do whatever needs to be done to find
          // delinquent orders in sql database.
          // filter first 30 records for example
       }
    }
    

    Note that repository interface brings domain into focus (we don’t say ‘all but first 30 records‘, we say ‘delinquent‘).

    The issue I’m running into is another developer who is sharing a project with me made all of his repositories (one per table) simply all use the same implementation that simply copies properties of a LinqToSql type to a domain type. There’s no logic in the repository itself other than updating and deleting or getting data by a Func supplied.

    I on the other hand created a repository (that inherited from IRepository of T) for each table and put specific logic in some (not all) where I felt logic was needed to hand back the domain objects.

    Generic repository interface is usually a bad idea, it is too data-centric, too CRUDy, please see this answer for details and links.

    So in my case, business logic could be done in the repository, in his case it has to be done by the user which could be a service or the ViewModel directly. Which is more preferred?

    There is a big difference between business logic and data access logic. You want to avoid putting business logic into repository implementation. This logic belongs to domain objects.

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

Sidebar

Related Questions

I always have the the trouble in determining whether I should put business logic
I have this wcf method Profile GetProfileInfo(string profileType, string profileName) and a business rule:
I have a question regarding the method i am using for doing Business Rule
I have a problem with the code analysis rule CA1726:UsePreferredTerms . Our business domain
I have a business user who tried his hand at writing his own SQL
I currently have a business object with a validation business rule, which is it
I have a requirement to build a Business Rule Engine. I use the SQL
I am using the Repository Pattern for my application. I have a class User.
I have an ASP.NET 3.5 page with some AJAX, some Validators and some business-rule
I have a ASP.NET AJAX Calender and a TextBox. I want the user should

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.