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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:36:17+00:00 2026-06-16T03:36:17+00:00

We use an Ioc Container to resolve most of the objects in a project,

  • 0

We use an Ioc Container to resolve most of the objects in a project, however it seems like it might be innappropriate to use it everywhere. At runtime, the user is in the context of a single company Id and it seems appropriate to me to pass that company Id in the constructor of, for example, a repository or unit of work. We could use a parameter override for the company Id at runtime, but is there any benefit in using

var uow = IocContainer.Resolve<IUnitOfWork>(new ParameterOverride("companyId", companyId))

as opposed to

var uow = new UnitOfWork(companyId)

OK, so I understand that I might want to create a different implementation of IUnitOfWork some time and I could then easily swap in the new implementation with Ioc configuration, but I am not convinced I will ever do that anyway.

  • 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-16T03:36:19+00:00Added an answer on June 16, 2026 at 3:36 am

    No, there are times when calling new is exactly what you want. An example would be an object local to a method call or a narrow scope.

    Model objects usually aren’t under the control of an IoC container. You instantiate one for each new session or request scope, using data passed to you from users that can never be known by the IoC container on startup.

    Update: Honza Brestan’s point about logical units is spot on. The typical Spring layer arrangment is interface-based:

    view->controller->service->persistence
    

    Services use other services, model objects and persistence to fulfill use cases.

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

Sidebar

Related Questions

Possible Duplicate: Why not use an IoC container to resolve dependencies for entities/business objects?
I am looking to use an IOC container in my current project which is
I have decided to use IoC principles on a bigger project. However, i would
I am using wcf 4 and trying to use some Ioc container to resolve
I'm using the Unity IoC container for resolving my objects. However, I've run into
I manage my objects with a IoC-container (autofac). Because of that I only use
I'd like to use Unity as an IoC container for an ASP.NET MVC 3
I generally use IoC pattern in my projects which are most of the time
I have been using the Windsor IoC Container for my web-based application, to resolve
I use Castle Windsor IoC. I would like configure object in IoC from XML

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.