title: Reflection on IQueryable<T> can't find property
body: <p>I created a custom gridview control and exported it into a dll so I can reuse it. Inside the dll I created a function to get the DataSource, I'm trying to fill a dropdown from there but is failing.</p>
  
  <p>So on my website I have this</p>
  
  <pre><code>public partial class _Management : System.Web.UI.Page
  {
      public class _ManagementHelper
      {
          public int ID;
          public string CompanyName;
          public string ResourceName;
      }
  
      protected void Page_Load(object sender, EventArgs e)
      {    
          ucGridViewEx.DataSource = ucGridViewEx_Source();
          ucGridViewEx.DataBind();
      }
  
      private List&lt;dynamic&gt; ucGridViewEx_Source()
      {
          var source = dl.ComapniesResources.Select(x =&gt; new _ManagementHelper
          {
              ID = x.ResourceID,
              CompanyName = x.Supplier1.SupplierName,
              ResourceName = x.Name
          });
  
          return ucGridViewEx.GridViewExDataSource(source);
  }
  </code></pre>
  
  <p>Then the custom control inside the dll have this relevant code</p>
  
  <pre><code>public List&lt;dynamic&gt; GridViewExDataSource&lt;T&gt;(IQueryable&lt;T&gt; query)
  {
      foreach (var column in this.Columns)
      {
          var gridViewExColumn = column as ColumnEx;
          if (gridViewExColumn != null
              &amp;&amp; gridViewExColumn.SearchType == SearchTypeEnum.DropDownList)
          {
              gridViewExColumn.DropDownDataSource = query.GetDropDownDataSource(gridViewExColumn.DataField);
          }
      }
  
      return ((IQueryable&lt;dynamic&gt;)query).ToList&lt;dynamic&gt;();
  }
  </code></pre>
  
  <p>Function GetDropDownDataSource() is inside another extension class inside the same dll as the gridview</p>
  
  <pre><code>internal static List&lt;ListItem&gt; GetDropDownDataSource&lt;T&gt;(this IQueryable&lt;T&gt; query,
      string dataField)
  {
      var ddlSource = new List&lt;ListItem&gt;();
  
      // x =&gt;
      var xParameter = Expression.Parameter(typeof(T), "x");
  
      // x.Property
      var propery = typeof(T).GetProperty(dataField);
  
      // x =&gt; x.Property
      var columnLambda = Expression.Lambda(Expression.Property(xParameter, propery), xParameter);
  
      return ddlSource;
  }
  </code></pre>
  
  <p>Code fails in this where I'm assingning the value to columnLambda because property is null, not because it does not exist (it does) because is not getting any property. I tried with GetProperties() and is not returning anything.</p>
  
  <p>Is curious than this is happening since I moved to the DataSource to select into _ManagementHelper. I was using a dynamic ( Select(x => new {}) ) on ucGridViewEx_Source() before and it worked perfectly. Please don't provide the solution to keep using the dynamic because I need to allow both types, with dynamic and using custom objects.</p>