title: Convert LINQ return type to C# class
body: <p>I have a LINQ query against my DBModel classes which is returning an anonymous type. I have to convert it to a known C# class type.</p>
  
  <p>I can directly use the known type in DBModel class but it's not allowed to use any known types in my project architecture.</p>
  
  <p>Example:</p>
  
  <pre><code>static dynamic getEmployees()
  {
      SampleDB db = new SampleDB();
      var result = (from x in db.Employes
      select new
      {
          name = x.FirstName + " " + x.LastName,
          department = x.DepartmentId
      });
      return result;
  }
  </code></pre>
  
  <p>My known type:</p>
  
  <pre><code>public class Emp
  {
      public string name { set; get; }
      public int department { set; get; }
  }
  </code></pre>
  
  <p>Program:</p>
  
  <pre><code>dynamic d = getEmployees();
  List&lt;Emp&gt; result = d.cast&lt;Emp&gt;();
  //Other code....
  </code></pre>
  
  <p>How can I cast the dynamic type to List? In <code>getEmployees</code> I can't use like </p>
  
  <pre><code>static List&lt;Emp&gt; getEmployees()
  {
      SampleDB db = new SampleDB();
      var result = (from x in db.Employes
      select new Emp
      {
          name = x.FirstName + " " + x.LastName,
          department = x.DepartmentId
      }).ToList();
  
      return result;
  }
  </code></pre>
  
  <p>Can anybody tell me how can I cast the LINQ return type to a known type?</p>