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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:27:25+00:00 2026-06-17T17:27:25+00:00

I am a lone developer and Pluralsight is my salvation in helping me understand

  • 0

I am a lone developer and Pluralsight is my salvation in helping me understand things like Repository and IoC, which I am just learning.
However I am finding the pattern awkward to use.

So I am using Unity IoC, and following ModelContainer class;

public static class ModelContainer
{
    private static IUnityContainer instance;

    static ModelContainer()
    {
        instance = new UnityContainer();
    }

    public static IUnityContainer Instance
    {
        get
        {
            instance.RegisterType<ISCD_CallDiaryRepository, SCD_CallDiaryRepository>(new HierarchicalLifetimeManager());
            instance.RegisterType<ICompanyRepository, CompanyRepository>(new HierarchicalLifetimeManager());
            instance.RegisterType<ISubcontractorRepository, SubcontractorRepository>(new HierarchicalLifetimeManager());
            instance.RegisterType<ITradeRepository, TradeRepository>(new HierarchicalLifetimeManager());
            instance.RegisterType<IEmployeeRepository, EmployeeRepository>(new HierarchicalLifetimeManager());
            instance.RegisterType<ISubcontractorTradeRepository, SubcontractorTradeRepository>(new HierarchicalLifetimeManager());
            instance.RegisterType<ICountyRepository, CountyRepository>(new HierarchicalLifetimeManager());
            instance.RegisterType<IAddressLineRepository, AddressLineRepository>(new HierarchicalLifetimeManager());
            return instance;
        }
    }
}

allows me to instantiate the repository classes in the constructor of my controller;

public SubcontractorController(
        ISubcontractorRepository subcontractorRepository,
        ISubcontractorTradeRepository subcontractorTradeRepository, 
        ICompanyRepository companyRepository, 
        ISCD_CallDiaryRepository scdCallDiaryRepository,
        ITradeRepository tradeRepository,
        IAddressLineRepository addressLineRepository)
    {
        this.SubcontractorRepository = subcontractorRepository;
        this.SubcontractorTradeRepository = subcontractorTradeRepository;
        this.CompanyRepository = companyRepository;
        this.ScdCallDiaryRepository = scdCallDiaryRepository;
        this.TradeRepository = tradeRepository;
        this.AddressLineRepository = addressLineRepository;
    }

What I find awkward about this setup is that if I want to use the CRUD functionality in these repository classes, I have to either do the functionality in the controllers, or pass the repository instance I have created as a parameter into the model class methods. I choose the latter, controllers are not meant to do much, but it doesn’t seem right to me to have to keep passing the repository parameter around.

What am I missing?

  • 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-17T17:27:26+00:00Added an answer on June 17, 2026 at 5:27 pm

    In provided sample, there is SubcontractorController controller with six dependecies, what is usually means that the controller tries to do too much at once, and could possibly violates Single responsibility principle. There are at least three way to improve situation:

    • Instead of injecting repositories into a controller, and passing the repository instance as a parameter into the model class methods, you could refactor to Aggregate Services, i.e. combine both models method and dependencies in single entity. This will also solve constructor over-injection.
    • Inject a factory of repositories into the controller, and later resolve dependencies using this factory
    • Inject models themselves, and make repositories to be their dependencies.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a lone developer who would like to get some structure to my projects.
I'm trying fossil as my new VCS, since I'm a lone developer working on
This might be a stupid question, but if I'm a lone developer and only
I'm just getting into the practice of version control (I'd like to use Eclipse
I've just joined a team which has been working in a main-always mode for
I work as a lone developer in a very small company. My work is
I am a lone developer. We have a couple of websites hosted on a
I am the lone .NET developer in an non-IT organization. I've been asked to
It's my first time using a DVCS and also as a lone developer, the
Since I am a Lone Developer, I have to think about every aspect of

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.