title: Enumerable Select by Expression Tree
body: <p>I'm studying "Expression Tree" but I'm not managing to perform these expressions:</p>
  
  <pre><code>// first case
  someList.Select(p =&gt; p.SomeProperty);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>// second case
  someList.Select(p =&gt; new OtherClass 
  {
      SomeProperty = p.SomeProperty
  })
  </code></pre>
  
  <p>To the "first case" I tried do this:</p>
  
  <pre><code>var someList = new List&lt;SomeClass&gt;();
  someList.Add(new SomeClass { SomeProperty = "Hello" });
  
  var someParam = Expression.Parameter(typeof(SomeClass), "p");
  var someProperty = Expression.Property(someParam, "SomeProperty");
  
  Expression.Call(
      typeof(Enumerable),
      "Select",
      new Type[]
      {
          typeof(SomeClass),
          typeof(string)
      },
      Expression.Lambda(
          someProperty,
          someParam
      )
  ).Dump();
  </code></pre>
  
  <p>But I get this error:</p>
  
  <p><em>InvalidOperationException: No generic method 'Select' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.</em> </p>
  
  <p>About the "second case", I don't have ideia how to proceed.</p>
  
  <p>Can anyone guide me here?</p>