title: How to convert PropertyInfo to property expression and use it to invoke generic method?
body: <p>How to convert <a href="http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.aspx" rel="nofollow noreferrer"><code>PropertyInfo</code></a> to property expression which can be used to invoke <a href="http://msdn.microsoft.com/en-us/library/gg671225%28v=vs.103%29.aspx" rel="nofollow noreferrer"><code>StructuralTypeConfiguration&lt;TStructuralType&gt;.Ignore&lt;TProperty&gt;(Expression&lt;Func&lt;TStructuralType, TProperty&gt;&gt; propertyExpression)</code></a> method?</p>
  
  <p>I tried to use <a href="http://msdn.microsoft.com/en-us/library/bb348662.aspx" rel="nofollow noreferrer"><code>Expression.Property()</code></a> to construct expression but I am getting following error when I use this expression as <code>propertyExpression</code> parameter: </p>
  
  <p><code>The type arguments for method cannot be inferred from the usage. Try specifying the type arguments explicitly.</code></p>
  
  <p>This error probably refers to <code>TProperty</code> type parameter which I don't know how to specify having only <code>PropertyInfo</code>.</p>
  
  <p>I am doing this in relation to: <a href="https://stackoverflow.com/questions/9585263/use-entity-frameworks-structuraltypeconfiguration-ignore-to-ignore-all-proper">Use Entity Framework&#39;s StructuralTypeConfiguration.Ignore() to Ignore all properties but specified set</a>.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Code which is not working:</p>
  
  <pre><code>var propertyInfo = typeof(Foo).GetProperties()[0];
  var expression = Expression.Default(typeof(Foo));
  var expressionProperty = Expression.Property(expression, propertyInfo);
  Ignore(expressionProperty);
  </code></pre>