title: Mapping using Expression Trees? Is it possible to implement this?
body: <pre><code>public static MapFrom Map(this IDataReader idr, params string[] columns)
  {
       return new MapFrom { Columns = columns };
  }
  public static IEnumerable&lt;TEntity&gt; To&lt;TEntity&gt;(this MapFrom from, Func&lt;TEntity, object&gt; map)
  {
       // logic here.
  }    
  
  public IEnumerable&lt;FooEntity&gt; Execute()
  {
      using (DbCommand cmd = db.GetStoredProcCommand("GetListOfFoo"))
      {
          using (IDataReader idr = db.ExecuteReader(cmd))
          {
              return idr.Map("FooID", "FooOfPooAmount", "AnotherFooColumn", "BarID")
                .To&lt;FooEntity&gt;(x =&gt; new object[]{
                            x.FooID, x.FooOfPooAmount, x.AnotherFoo, x.BarID
              });
           }
       }
  }
  </code></pre>
  
  <p>I wish to take a data reader and create a simple mapper that is easy to use and is also performant. I haven't used expression trees much, but I feel like they may be needed. What I want to do is inspect the <em>relationship</em> of  x to it's array (The lambda expression), and then use this relationship to automatically map values appropriately and create a new List of Foo Entitiies.</p>
  
  <p>MapFrom is just a container to carry information and allow fluent extension methods. </p>
  
  <p>The point of these acrobatics is to have a simple way to specify relationships. I realize I could easily do something like in a different form, but I wanted to be able to list columns "fluently" [1] (as in typing column name as a string followed by comma then next column name) and then list the object properties in sequential order and infer the mapping from this. It it possible to implement the <strong>To</strong> method above? Are Expression Trees appropriate here? I figure I can easily enough infer type casting for the data reader fields from the FooEntity property types.</p>
  
  <p>[1] In this context I do not mean fluent as in "Fluent API"</p>