title: Converting lambda expression into an expression tree
body: <p>From C# in depth:</p>
  
  <blockquote>
    <p>Not all lambda expressions can be converted to expression trees. You
    can’t convert a lambda with a block of statements ( even just one
    return statement ) into an expresion tree --> it has to be in the form
    that just evaluates a single expression.</p>
  </blockquote>
  
  <p>Since Linq-to-Object statements don't get converted into expression tree objects, the lambda expressions used with Linq-to-Object operators can contain a block of statements </p>
  
  <pre><code>        string[] count = { "one ", "two ", "three ", "four ", "five ", "six " };
          IEnumerable&lt;int&gt; result = count.Select(item =&gt;
                                 {
                                     Console.WriteLine(item);
                                     return item.Length;
                                 });
          foreach (int i in result);
  </code></pre>
  
  <p>OUTPUT: </p>
  
  <pre><code>one two three four five six
  </code></pre>
  
  <p>I haven't yet started learning Linq-To-Sql or Linq-To-Entities, but I assume lambda expressions used with LINQ statements that operate on <code>IQueryable&lt;T&gt;</code> can only ever contain a single expression, due to restristion that only a single expression can be converted into an expression tree?</p>
  
  <p>Thank you</p>