title: Reading Properties of an Object with Expression Trees
body: <p>I want to create a Lambda Expression for every Property of an Object that reads the value dynamically.</p>
  
  <p>What I have so far:</p>
  
  <pre><code>var properties = typeof (TType).GetProperties().Where(p =&gt; p.CanRead);
  
  foreach (var propertyInfo in properties)
  {
      var getterMethodInfo = propertyInfo.GetGetMethod();
  
      var entity = Expression.Parameter(typeof (TType));
  
      var getterCall = Expression.Call(entity, getterMethodInfo);
  
      var lambda = Expression.Lambda(getterCall, entity);
      var expression = (Expression&lt;Func&lt;TType, "TypeOfProperty"&gt;&gt;) lambda;
      var functionThatGetsValue = expression.Compile();
  }
  </code></pre>
  
  <p>The code Works well when i call <code>functionThatGetsValue</code> as long as "TypeOfProperty" is hardcoded. I know that I can't pass the "TypeOfPoperty" dynamically. What can I do to achive my goal?</p>