title: How to reduce number of injected dependencies on controller
body: <p>I am using MVC3, Entity Framework v4.3 Code First, and SimpleInjector. I have several simple classes that look like this:</p>
  
  <pre><code>public class SomeThing
  {
      public int Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>I have another entity that looks like this:</p>
  
  <pre><code>public class MainClass
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public virtual AThing AThingy { get; set; }
      public virtual BThing BThingy { get; set; }
      public virtual CThing CThingy { get; set; }
      public virtual DThing DThingy { get; set; }
      public virtual EThing EThingy { get; set; }
  }
  </code></pre>
  
  <p>Each Thingy (currently) has its own Manager class, like so:</p>
  
  <pre><code>public class SomeThingManager
  {
      private readonly IMyRepository&lt;SomeThing&gt; MyRepository;
  
      public SomeThingManager(IMyRepository&lt;SomeThing&gt; myRepository)
      {
          MyRepository = myRepository;
      }
  } 
  </code></pre>
  
  <p>My MainController consequently follows:</p>
  
  <pre><code>public class MainController
  {
      private readonly IMainManager MainManager;
      private readonly IAThingManager AThingManager;
      private readonly IBThingManager BThingManager;
      private readonly ICThingManager CThingManager;
      private readonly IDThingManager DThingManager;
      private readonly IEThingManager EThingManager;
  
      public MainController(IMainManager mainManager, IAThingManager aThingManager, IBThingManager bThingManager, ICThingManager cThingManager, IDThingManager dThingManager, IEThingManager eThingManager)
      {
          MainManager = mainManager;
          AThingManager = aThingManager;
          BThingManager = bThingManager;
          CThingManager = cThingManager;
          DThingManager = dThingManager;
          EThingManager = eThingManager;
      }
  
      ...various ActionMethods...
  }
  </code></pre>
  
  <p>In reality, there are twice as many injected dependencies in this controller. It smells. The smell is worse when you also know that there is an OtherController with all or most of the same dependencies. I want to refactor it.</p>
  
  <p>I already know enough about DI to know that property injection and service locator are not good ideas. </p>
  
  <p>I can not split my MainController, because it is a single screen that requires all these things be displayed and editable with the click of a single Save button. In other words, a single post action method saves everything (though I'm open to changing that if it makes sense, as long as it's still a single Save button). This screen is built with Knockoutjs and saves with Ajax posts if that makes a difference.</p>
  
  <p>I humored the use of an Ambient Context, but I'm not positive it's the right way to go.
  I humored the use of injecting a Facade as well.
  I'm also wondering if I should implement a Command architecture at this point.
  (Don't all of the above just move the smell somewhere else?)</p>
  
  <p>Lastly, and perhaps independent of the three above approaches, is should I instead have a single, say, LookupManager with explicit methods like GetAThings(), GetAThing(id), GetBThings(), GetBThing(id), and so on? (But then that LookupManager would need several repositories injected into it, or a new type of repository.)</p>
  
  <p>My musings aside, my question is, to reiterate: what's a good way to refactor this code to reduce the crazy number of injected dependencies?</p>