title: How to add Select to an existing Linq Expression
body: <p>I'm trying to make an editable table. I have a dynamic table, columns can be made visible or invisible. I have an extra column with an edit button. When I hit this I do an Ajax call to get an editable version of the row.</p>
  
  <p>My viewmodel:</p>
  
  <pre><code>public class List: IDynamicGridDataModel&lt;View&gt;
  {
      public List()
      {
          ColumnOptions = new ColumnOptions();
          ColumnOptions.SelectedColumns = new List&lt;string&gt;() { "Address", "ZipCode", "City", "Country" };
          ColumnOptions.DisabledColumns = new List&lt;string&gt;() { "Id" };
  
          Items = new List&lt;View&gt;();
      }
  
      #region IDynamicGridDataModel&lt;View&gt; Members
  
      public ColumnOptions ColumnOptions { get; set; }
      public GridModel&lt;View&gt; GridModel { get; set; }
      public IEnumerable&lt;View&gt; Items { get; set; }
  
      #endregion
  }
  </code></pre>
  
  <p>Where the items are:</p>
  
  <pre><code>public class View
  {
      public long Id { get; set; }
      public string Address { get; set; }
      public string ZipCode { get; set; }
      public string City { get; set; }
      public string Country { get; set; }
  }
  </code></pre>
  
  <p>I have the following extension to create the table row:</p>
  
  <pre><code>public static MvcHtmlString EditorRowFor&lt;TModel, TRow&gt;(this HtmlHelper&lt;TModel&gt; html, Expression&lt;Func&lt;TModel,TRow&gt;&gt; expression, IEnumerable&lt;string&gt; selectedColumns)
  {
      var metadataProvider = new DataAnnotationsModelMetadataProvider();
      var stringBuilder = new StringBuilder();
  
      stringBuilder.Append("&lt;tr&gt;");
  
      foreach (var column in selectedColumns)
      {
          var entityParam = Expression.Parameter(expression.ReturnType);
  
          var columnLambda = Expression.Lambda(Expression.Property(entityParam, typeof(TRow), column));
  
          var selectCall = Expression.Call(typeof(Queryable),
                                           "Select",
                                           new Type[] { typeof(TModel), columnLambda.Body.Type },
                                           expression,
                                           columnLambda);
  
         html.EditorCellFor(selectCall);
  
          stringBuilder.AppendLine("&lt;/td&gt;");
      }
  
      stringBuilder.AppendLine("&lt;/tr&gt;");
      return new MvcHtmlString(stringBuilder.ToString());
  }
  </code></pre>
  
  <p>This function is called from my view like this:</p>
  
  <pre><code>@Html.EditorRowFor(m =&gt; m.Items.Single(), Model.ColumnOptions.SelectedColumns);
  </code></pre>
  
  <p>The EditorCellFor method signature:</p>
  
  <pre><code>public static MvcHtmlString EditorCellFor&lt;TModel, TItem&gt;(this HtmlHelper&lt;TModel&gt; html, Expression&lt;Func&lt;TModel, TItem&gt;&gt; expression)
  </code></pre>
  
  <p>My current problem is with the creation of the selectCall. I want to make an Expression for the Lambda expression:</p>
  
  <pre><code>m =&gt; m.Items.Single().Select(i =&gt; i.Address)
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>No generic method 'Select' on type 'System.Linq.Queryable' is compatible with 
  the supplied type arguments and arguments. No type arguments should be 
  provided if the method is non-generic.
  </code></pre>
  
  <p>Most of the code surrounding that part I saw on <a href="http://www.hanselman.com/blog/TheWeeklySourceCode47ASPNET35DynamicDataFilterRepeatersAndDynamicLinqQueryGeneration.aspx" rel="nofollow">http://www.hanselman.com/blog/TheWeeklySourceCode47ASPNET35DynamicDataFilterRepeatersAndDynamicLinqQueryGeneration.aspx</a>.</p>
  
  <p>I've been searching for the problem the entire morning but no luck so far.</p>