title: Creating a series of SQLite tables from a list of classes
body: <p>I have generated a list of public classes that need to be added into an SQLite database.</p>
  
  <p>I get the class names like this</p>
  
  <pre><code>private List&lt;Type&gt; types = new List&lt;Type&gt;();
  ...
  var pathName = Directory.GetFiles(string.IsNullOrEmpty(dirPath) ? "SQLClasses" : dirPath);
  foreach (var path in pathName)
      types.AddRange(Assembly.LoadFrom(path).GetTypes());
  </code></pre>
  
  <p>types now contains my classes that need to be turned into SQLite tables.</p>
  
  <p>Normally, I would create my tables like this</p>
  
  <pre><code>using (SQLiteConnection sqlCon = new SQLiteConnection(DBPath))
  {
       sqlCon.CreateTable&lt;TableName&gt;();
  </code></pre>
  
  <p>As I already have my list of classes held in types, I'm trying to insert these tables into the database using a simple foreach</p>
  
  <p>Currently I have this</p>
  
  <pre><code>foreach(var t in types)
  {
      var T = Activator.CreateInstance(t);
      sqlCon.CreateTable&lt;T&gt;();
  }
  </code></pre>
  
  <p>neither this nor the simpler</p>
  
  <pre><code>sqlCon.CreateTable&lt;typeof(t)&gt;();
  </code></pre>
  
  <p>or</p>
  
  <pre><code>sqlCon.CreateTable&lt;t&gt;();
  </code></pre>
  
  <p>work (all three give T [or t] doesn't exist in the current context)</p>
  
  <p>Can I use this simple foreach method to insert the table names or do I have to do something more complex?</p>