title: Using reflection to supply generic type to a method?
body: <p>I'm not sure this is possible with reflection, but thought I'd ask.  I'm using a data access class that relies on generics to determine the 'row type' which we're querying against.  </p>
  
  <p>A couple of examples will show what I mean better than anything:</p>
  
  <pre><code>int count1 = connection.Count&lt;PersonRow&gt;("i.FirstName ='David'");
  int count2 = connection.Count&lt;CarRow&gt;("i.CarModel = 'Chevrolet'"); 
  </code></pre>
  
  <p>Both <code>PersonRow</code> and <code>CarRow</code> inherit from an abstract <code>Row</code> class.</p>
  
  <p>As you can see, the type of <code>Row</code> we're querying against dictates what our query structure will be.</p>
  
  <p>I'd like to store a bunch of these queries as strings in a database or configuration file, rather than hard-code them.  That way we can let users write their own queries as they like, and the code loops over the configuration and runs them one at a time.</p>
  
  <p>Trouble is, I don't know if I can pull this off given the Generic requirement above?</p>
  
  <p>I'd love for the configuration to store the kind of row (as a string) along with a string for the query itself, then use reflection to supply the row class in the <code>Count&lt;&gt;</code> method.</p>
  
  <p>I've been playing with <code>Type.GetType()</code> and <code>Type.MakeGenericType()</code> to see if 
  I can finagle something, but am having no luck.  </p>
  
  <p>While looking around, I've seen several articles like <a href="https://stackoverflow.com/questions/266115/pass-an-instantiated-system-type-as-a-type-parameter-for-a-generic-class">this</a> that show how to instantiate a generic class using reflection, but I need the class type, not an actual object.  Is there a way to pull this off?</p>