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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:45:28+00:00 2026-05-30T05:45:28+00:00

I have a framework with a DDD data layer which uses the service locator

  • 0

I have a framework with a DDD data layer which uses the service locator pattern. However, currently I use a global static ServiceLocator class which stores all the references. I would like to refactor this into a correct implementation where classes implement the IServiceProvider interface and where I remove the global static ServiceLocator class.

Now, almost everywhere it isn’t issue to extend existing classes with the IServiceProvider interface, except for the entity classes. The problem is that I would think it very strange for the entity classes to have to implement IServiceProvider, but I do need a way to access a service provider to be able to resolve repositories through my IoC container.

What would be the best way to implement the service locator pattern without having to implement IServiceProvider on my entities?

  • 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-30T05:45:30+00:00Added an answer on May 30, 2026 at 5:45 am

    Why the heck would an entity (business object) expose IServiceProvider? It is a business object, not a service. And IServiceProvider is not even for services, it is an IOC mechanism to expose service providers.

    if anything, your ORM / business object framework / runtime is a service provider, but not the individual entities.

    let me return the question: I dont see any sensible programming concept where entities expose IServiceProvider to start with.

    —update

    Services only should provide a service locator – and you should have one. You can use thread static variables for those cases where defined threads access elements (name: UI for example – UI elements must be accessed by spec by the UI thread) which breaks the global singleton.

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

Sidebar

Related Questions

I have a Compact Framework 2.0 app that consume a WCF service. The data
I have a framework which works this way: After defining some meta data, it
I have a framework which currently requires pretty verbose setup in Spring: <bean id=dpHibernateRemotingAdapter
I have play-framework application that uses one module which I've created by play new-module
I have Entity Framework entities Events which have an EntityCollection of RSVP. I want
Does the .NET Compact Framework have a service pack? If so does anyone know
I have a .NET Framework 2.0 app and would like to use the Windows
I have a framework that uses log4net for logging, I know that we can
I'm trying to get to light. In DDD approach we have Presentation Layer(UI), Application
I have a framework library which would do a lot of things including logging.

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.