title: Create Expression<Func<T, object>> from a given Type
body: <p>I am looking to use CsvHelper dynamically by building up Expressions in code which represent property member access for a given type.</p>
  
  <p>The method I am trying to pass these expressions to has the following signature:</p>
  
  <pre><code>    public virtual CsvPropertyMap&lt;TClass, TProperty&gt; Map&lt;TProperty&gt;( Expression&lt;Func&lt;TClass, TProperty&gt;&gt; expression )
      {
          //
      }
  </code></pre>
  
  <p>So you would normally call it, for any given type you want to map, like this (for a type with a property called 'stringProperty'):</p>
  
  <pre><code>mapper.Map(x =&gt; x.StringProperty);
  </code></pre>
  
  <p>Passing in a lambda which is converted internally into an <code>Expression&lt;Func&lt;T, object&gt;&gt;</code></p>
  
  <p>I have tried to create this expression in code, using Expressions. At compile time it all works fine (in that it returns an <code>Expression&lt;Func&lt;TModel, object&gt;&gt;</code>), but at runtime I get an exception 'not a member access'. Here is the code which takes a PropertyInfo object representing the property I want to map:</p>
  
  <pre><code>    private Expression&lt;Func&lt;TModel, object&gt;&gt; CreateGetterExpression( PropertyInfo propertyInfo )
      {
          var getter = propertyInfo.GetGetMethod();
  
          Expression&lt;Func&lt;TModel, object&gt;&gt; expression = m =&gt; getter.Invoke( m, new object[] { } );
          return expression;
      }
  </code></pre>
  
  <p>Basically, how do I build that Expression up properly in code?</p>