title: How do I create a Linq expression tree with an F# lambda?
body: <p>Here's what can be done in C# -</p>
  
  <pre><code>var two = 2;
  System.Linq.Expressions.Expression&lt;System.Func&lt;int, int&gt;&gt; expr = x =&gt; x * two;
  expr.Compile().Invoke(4); // returns 8
  </code></pre>
  
  <p>I wish to do the precise equivalent in F#. Here's what I tried, but did not compile -</p>
  
  <pre><code>let two = 2
  let expr = (fun x -&gt; x * two) : System.Linq.Expressions.Expression&lt;System.Func&lt;int, int&gt;&gt;
  expr.Compile().Invoke(4) // desired to return 8
  </code></pre>
  
  <p>Perhaps predictably, compilation fails on line 2 with the following error -</p>
  
  <pre><code>"This function takes too many arguments, or is used in a context where a function is not expected."
  let expr = (fun x -&gt; x * two) : System.Linq.Expressions.Expression&lt;System.Func&lt;int, int&gt;&gt;
              ^^^^^^^^^^^^^^^^
  </code></pre>