title: Cast ExpandoObject to anonymous type
body: <p>Can I cast ExpandoObject to anonymous type ?</p>
  
  <pre><code>var anoObj = new { name = "testName", email = "testEmail" };
  
  dynamic expandoObj = new System.Dynamic.ExpandoObject();
  
  // Here I'm populating the expandoObj with same property names/types in anonymoustype(anoObj)
  
  // Now, how to convert this ExpandoObject to anonymoustype ?
  
  var newObj = (typeof(anoObj)expandoObj); // This doesn't work
  </code></pre>
  
  <h2>Added Later</h2>
  
  <p>// This is my entity</p>
  
  <pre><code>public class Customer
      {
          #region Public Properties
  
          [ColumnAttribute(Name = "IdColumn")]
          public string Id { get; set; }
  
          [ColumnAttribute(Name = "NameColumn")]
          public string Name { get; set; }
  
          [ColumnAttribute(Name = "AddressColumn")]
          public string Address { get; set; }
  
          [ColumnAttribute(Name = "EmailColumn")]
          public string Email { get; set; }
  
          [ColumnAttribute(Name = "MobileColumn")]
          public string Mobile { get; set; } 
  
          #endregion
      }
  </code></pre>
  
  <p>// -------------------------------------------------------------------------------------</p>
  
  <pre><code>public class LookupService&lt;TEntitySource&gt;
  {
      public LookupService ()
      {
  
      }
  
      public LookupShowable&lt;TEntitySource, TSelection&gt; Select&lt;TSelection&gt;(Expression&lt;Func&lt;TEntitySource, TSelection&gt;&gt; expression)
      {
          var lookupShowable = new LookupShowable&lt;TEntitySource, TSelection&gt;();
  
          return lookupShowable;
      }
  }
  
  public class LookupShowable&lt;TEntitySource,TSelection&gt;
  {
      public LookupShowable()
      {
  
      }
  
      public LookupExecutable&lt;TEntitySource, TSelection, TShow&gt; Show&lt;TShow&gt;(Expression&lt;Func&lt;TEntitySource, TShow&gt;&gt; expression)
      {
          var lookupExecutable = new LookupExecutable&lt;TEntitySource,TSelection,TShow&gt;();
  
          return lookupExecutable;
      }
  }
  
  public class LookupExecutable&lt;TEntitySource, TSelection, TShow&gt;
  {
      public TSelection Execute()
      {
         // Here I want to create a new instance of TSelection and populate values from database and return it.
      }
  }
  </code></pre>
  
  <p>//--------------------------------------------------------------------------------------</p>
  
  <pre><code>// This is How I want to call this from front end...
      var lookupService = new LookupService&lt;Customer&gt;();
      var lookupSelection = lookupService.Select(C =&gt; new { C.Id, C.Name, C.Mobile }).Show(C =&gt; new { C.Id, C.Name}).Execute();
  
  
      string sID = lookupSelection.Id;
      string sName = lookupSelection.Name;
      string sMobile = lookupSelection.Mobile;
  </code></pre>
  
  <p>Dont think about this middle part.. Purpose of it is another one...</p>
  
  <p>My problem is in Execute() method in LookupExecutable class. I dont know how to create a new instance of TSelection type and assign values to it. This TSelection type is always an anonymous type..</p>