title: Creating anonymous types based on lambda expression
body: <p>I'm trying to create a Fluent Interface to the Winforms Datagrid. This should allow me to use a typed datasource and easy use of properties of properties (Order.Custom.FullName)</p>
  
  <p>I'm adding the columns on initialization and trying to set the property to use there:</p>
  
  <pre><code>dgv.With&lt;Order&gt;().Column("Client Name").On(x =&gt; x.Client.FullName);
  </code></pre>
  
  <p>The original question then poses itself when setting the Datasource:</p>
  
  <pre><code>dgv.SetTypedDatasource&lt;T&gt;(IList&lt;Order&gt; orders)
  </code></pre>
  
  <p>A big problem here is that Generic Controls are not possible (I guess), so that T cannot be specified for the class, but has to be specified per method...</p>
  
  <p>I want to create a list of anonymous types, based on a given property in a lambda expression:</p>
  
  <p>something like:</p>
  
  <pre><code>ProcessList&lt;Client&gt;(clientList, x =&gt; x.FullName);
  </code></pre>
  
  <p>Is it possible to do something like this:</p>
  
  <p>[Edit] Note that in practice, the expressions will be set earlier, and will be fetched elsewhere...</p>
  
  <pre><code>public void ProcessList&lt;T&gt;(IList&lt;T&gt; sourceList, Expression&lt;Func&lt;T, object&gt;&gt; expression)
  {
      var list =
          (from T x
           in sourceList
           select new { expression })
           .ToList();
  
      // process list ....  grid.DataSource = list;
  }
  </code></pre>
  
  <p>So, I would like to create anonymous types based on the given expression. I know I can evaluate that expression to retrieve the correct properties.</p>
  
  <p>I'm kinda stuck, is something like this possible?</p>
  
  <p>Any ideas?</p>