title: Interface for ViewModel Builders in MVC
body: <p>I've been trying to make up my mind on how to deal with ViewModels in my MVC solution. I think, after reading different posts and blogs, that the best approach is having builders that implement an interface and then inject those into the controller itself.</p>
  
  <p>Using automapper I would do the mapping between the entities and the viewmodels in the implementation of each builder and the controllers will remain very thin.</p>
  
  <p>So I create this interface</p>
  
  <pre><code>public interface IViewModelBuilder&lt;TViewModel, TEntity&gt;
  {
      TViewModel Build(TEntity entity);
  }
  </code></pre>
  
  <p>For the moment I ignore the warnings about making them covariant and contravariant (don't know if that's needed).</p>
  
  <p>For a particular ViewModel though I need to fetch two entities from two different services so I don't know what type argument should I pass.</p>
  
  <pre><code>public class ConcreteVMBuilder: IViewModelBuilder&lt;concreteVM, ????&gt;
  </code></pre>
  
  <p>Maybe that interface is not correct?</p>
  
  <p>I understand merging the two entities fetched in the controller is not a clean solution, right?</p>
  
  <p>If someone could give me a hand I would be very much obliged</p>