title: Can you pass generic delegate without the type parameter?
body: <p>I have three projects </p>
  
  <ol>
  <li>MVC Web application</li>
  <li>Service application which is kind of two layers business/repository</li>
  <li>Entity framework (all EF configuration lives here)</li>
  </ol>
  
  <p><strong>MVC</strong> references > service</p>
  
  <p><strong>Service</strong>  references > EF</p>
  
  <p>I have these three methods currently that do some work. </p>
  
  <pre><code>public bool StoreUpload&lt;T&gt;(UploadInformation information) 
     where T : class, IUploadEntity { }
  
  public bool RemoveUpload&lt;T&gt;(UploadInformation information) 
     where T : class, IUploadEntity { }
  
  public bool CommitUpload&lt;T&gt;(UploadInformation information) 
     where T : class, IUploadEntity { }
  </code></pre>
  
  <p>I call these three methods from my controller using these interfaces which delegate to the work methods above:</p>
  
  <pre><code>Boolean StoreUpload(UploadInformation information);
  Boolean RemoveUpload(UploadInformation information);
  Boolean CommitStoredDocuments(UploadInformation information);
  </code></pre>
  
  <p>Based on a condition from UploadTypes enumeration in a switch I call the correct work method. I do this because I don't want my mvc project to have access to the EF database types otherwise I know someone is going to start querying data from all over the application. I use these switch statements for all interfaced methods:</p>
  
  <pre><code>public bool StoreUpload(UploadInformation information)
  {            
      switch (information.Type)
      {
          case UploadTypes.AutoIncident:
              return RemoveUpload&lt;AutoIncident&gt;(information);
          case UploadTypes.Incident:
              return RemoveUpload&lt;IncidentInjury&gt;(information);
          case UploadTypes.Inspection:
              return RemoveUpload&lt;Inspection&gt;(information);
          case UploadTypes.OtherIncident:
              return RemoveUpload&lt;OtherIncident&gt;(information);
          default:
              return false;
      }
  }
  
  public bool RemoveUpload(UploadInformation information) { ... }
  public bool CommitStoredUpload(UploadInformation information) { ... }
  </code></pre>
  
  <p>This method might shed a little light on what the types parameters are being used for. I am updating tables in a generic way using EF.</p>
  
  <pre><code>private bool CommitStoredDocuments&lt;T&gt;(UploadInformation information) where T : class, IUploadEntity
  {
          var uploads = GetStoredUploads(information.UniqueId);
          var entity = db.Set&lt;T&gt;().Include(e =&gt; e.Uploads)
               .Single(e =&gt; e.UniqueId == information.UniqueId);
          entity.Uploads.AddRange(uploads);
   ... 
  
  } 
  </code></pre>
  
  <p>It would be nice to be able to pass the work method which requires a type parameter as a delegate to the switch work method calls.</p>
  
  <pre><code>public bool DoSomeWork(delegateMethod, information) {
      switch(information.Type) { 
           case UploadTypes.AutoInciden:
             return delegateMethod&lt;AutoIncident&gt;(information);
           ...
      }
  } 
  </code></pre>
  
  <p>Can this be done?
  Also, I had trouble constructing a good title for this question so please comment if these is a better way to describe the challenge.</p>