title: Dynamic Linq Expression with return value
body: <p>I need to create a dynamic linq expression an i started work with many examples. I tested some and some work and some not. In this case i want to create a method that looks like :</p>
  
  <pre><code>public bool Check(int intvar)
  {
     if ( i &gt; 2 )
       return true;
     else
       return false;
  }
  </code></pre>
  
  <p>Now i have written the following :</p>
  
  <pre><code>LabelTarget returnTarget = Expression.Label("label");
  ParameterExpression para = Expression.Parameter(typeof(int), "intvalue");
  Expression test = Expression.GreaterThan(para, Expression.Constant(5));
  Expression iftrue = Expression.Return(returnTarget, Expression.Constant(true));
  Expression iffalse = Expression.Return(returnTarget,                   Expression.Constant(false));
  Expression.IfThenElse(test, iftrue, iffalse);
  
  this.TheExpression = Expression.IfThenElse(test, iftrue, iffalse);
  Expression.Lambda&lt;Action&lt;int&gt;&gt;(
  this.TheExpression,
  new ParameterExpression[] { para }
  ).Compile()(5);
  </code></pre>
  
  <p>Now it throws <code>InvalidOperationException</code>:</p>
  
  <blockquote>
    <p>Cannot jump to the label "label"`</p>
  </blockquote>
  
  <p>What is wrong ? I only need a return true or false.</p>