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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:43:53+00:00 2026-06-02T17:43:53+00:00

In a application that use Repositories and Services pattern, how to make sure Service

  • 0

In a application that use Repositories and Services pattern, how to make sure Service layer is always called and not the Repositories directly ?

Example :

class OrderRepository
{
    void CreateOrder(Order o)
    ...
}

class OrderService
{
    void CreateOrder(Order o)
    {
        //make some business logic tests
        ... 

        //call repository
        _orderRepository.CreateOrder(o);
    }
}

I see two issues :

  • A programmer may call the repository directly because it doesn’t know the existance of a service (sometimes its not as simple as in this example (1 service = 1 repository with same method names). some applications are not very well documented. or someone in hurry can forget to check if corresponding service exists (mistake)).

  • Totally different : long time ago someone created some views + controllers that use order repository directly. At that time there was no need to have some business logic check or additional operations, only order repository exists (because there it was not needed at all). If later, some additional operations when creating an order would be needed, a service will be created. the problem is that all controllers that make old repositories calls will need to be changed. Isn’t repository principle/idea (and separating code in layers) supposed to make parts independent from each other ?

  • 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-02T17:43:55+00:00Added an answer on June 2, 2026 at 5:43 pm

    You can structure your solution so that all repositories and services are in their own respective projects, ex. Repositories and Services.

    The only project that should reference Repositories would be Services. This way, other projects wouldn’t have access to the repositories. Of course, nothing is to stop a developer from including the repositories project to the controllers project, but hopefully at this point they’ll be asking themselves why it wasn’t included in the first place.

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

Sidebar

Related Questions

I have an application that makes use of/consumes services from a number of external
I have an application that makes use of frequently updated lists. So for example,
In Asp.NET applications, there is a service layer that stands between the repositories and
We have our Data Access Layer setup to use repositories, services, and specifications (for
I create new ASP.NET web application that use SMTP to send message. The problem
I have an C# form application that use an access database. This application works
I'm developing a web application that use Spring Security for authentication of users. I
I have C# application that makes use of some C libaries(which I have written
We have a Linux application that makes use of OpenSSL's Python bindings and I
I have a reference application that I use to work through DDD issues, and

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.