title: Dynamically building an expression tree
body: <p>I'm following this excellent example: <a href="https://stackoverflow.com/questions/5225416/convert-linq-to-sql-expression-to-expression-tree">Convert Linq to Sql Expression to Expression Tree</a></p>
  
  <p>In my case I'm trying to build an expression tree where the type to be filtered is only known at run time, and is expressed as a string. In the above example the type <em>Region</em> is already known and typed directly:</p>
  
  <pre><code>ParameterExpression pe = Expression.Parameter(typeof(Region), "region");
  </code></pre>
  
  <p>In my application I've been able to rewrite this as:</p>
  
  <pre><code>ParameterExpression pe = Expression.Parameter(Type.GetType("mystring"), "listData");
  </code></pre>
  
  <p>My stumbling block is this from the example:</p>
  
  <pre><code>MethodCallExpression whereCallExpression = Expression.Call(
              typeof(Queryable),
              "Where",
              new Type[] { query.ElementType },
              query.Expression,
              Expression.Lambda&lt;Func&lt;Region, bool&gt;&gt;(e3, new ParameterExpression[] { pe }));
  var results = query.Provider.CreateQuery&lt;Region&gt;(whereCallExpression);
  </code></pre>
  
  <p>In these two lines <em>Region</em> is directly typed. Is there a way of dynamically using a string "Region" to achieve the same thing?</p>