title: How to use ASP.NET MVC Generic Controller to populate right model
body: <p>I asked a question about ASP.NET MVC Generic Controller and <a href="https://stackoverflow.com/a/20001117/">this answer</a> shows a controller like this:</p>
  
  <blockquote>
  <pre><code>public abstract class GenericController&lt;T&gt; 
      where T : class
  {
      public virtual ActionResult Details(int id)
      {
          var model = _repository.Set&lt;T&gt;().Find(id);
          return View(model);
      }
  }
  </code></pre>
    
    <p>Which can be implemented like this.</p>
  
  <pre><code>public class FooController : GenericController&lt;Foo&gt;
  {
  
  }
  </code></pre>
    
    <p>Now when someone requests /Foo/Details/42, the entitiy is pulled from the _repository's <code>Set&lt;Foo&gt;()</code>, without having to write anything for that in the <code>FooController</code>. </p>
  </blockquote>
  
  <p>The way he explain that is good but think i want to develop a generic controller for product and customer where i will not use EF to load product &amp; customer model rather use MS data access application block.</p>
  
  <pre><code>public abstract class GenericController&lt;T&gt; 
          where T : class
      {
          public virtual ActionResult Details(int id)
          {
              //var model = _repository.Set&lt;T&gt;().Find(id);
              var model =customer.load(id);
              or 
              var model =product.load(id);
              return View(model);
          }
      }
  </code></pre>
  
  <p>So when request comes like <code>/Customer/Details/42 or /product/Details/11</code> then generic controller's details method will call but how we can detect that request comes from which controller and accordingly instantiate right class to load right model.</p>
  
  <p>If request comes for Customer then I need to load customer details from detail action method or if request comes for Product then I need to load Product details from detail action method of generic controller. </p>
  
  <p>How do I use generics to get the dataset of type <code>T</code> with the Entity Framework Data block?</p>