title: Result of join linq query to a viewmodel
body: <p>In my action method I am running the following query which returns a list : </p>
  
  <pre><code>var list = db.WorkRoles.
                  Join(db.WorkRolesUsersDetails,
                  o =&gt; o.WorkRoleId, od =&gt; od.WorkRoleId,
                  (o, od) =&gt; new
                  {
                      WorkRoleId = o.WorkRoleId,
                      RoleName = o.RoleName,
                      RoleDescription = o.RoleDescription,
                      CompanyId = o.CompanyId,
                      WRUDId = od.WRUDId,
                      UserDetailsId = od.UserDetailsId,
                      FocusStart = od.FocusStart,
                      FocusEnd = od.FocusEnd
                  }).ToList();
  </code></pre>
  
  <p>I have a viemodel in the same format looking like this : </p>
  
  <pre><code>public class RoleViewModel
  {
      public RoleViewModel(int workRoleId, string roleName, string roleDescription, int companyId, int wRUDId, string userDetailsId, DateTime focusStart, DateTime focusEnd)
      {
          WorkRoleId = workRoleId;
          RoleName = roleName;
          RoleDescription = roleDescription;
          CompanyId = companyId;
          WRUDId = wRUDId;
          UserDetailsId = userDetailsId;
          FocusStart = focusStart;
          FocusEnd = focusEnd;
      }
      int WorkRoleId { get; set; }
      string RoleName  { get; set; }
      string RoleDescription { get; set; }
      int CompanyId { get; set; }
      int WRUDId { get; set; }
      string UserDetailsId { get; set; }
      DateTime FocusStart { get; set; }
      DateTime FocusEnd { get; set; }
  }
  </code></pre>
  
  <p>What is the best way to convert the result of my query to a list of my viewmodel?</p>
  
  <p>One thing I've tried from answers here on stackoverflow is : </p>
  
  <pre><code>var list = db.WorkRoles.
                  Join(db.WorkRolesUsersDetails,
                  o =&gt; o.WorkRoleId, od =&gt; od.WorkRoleId,
                  (o, od) =&gt; new
                  {
                      WorkRoleId = o.WorkRoleId,
                      RoleName = o.RoleName,
                      RoleDescription = o.RoleDescription,
                      CompanyId = o.CompanyId,
                      WRUDId = od.WRUDId,
                      UserDetailsId = od.UserDetailsId,
                      FocusStart = od.FocusStart,
                      FocusEnd = od.FocusEnd
                  }).ToList()
                  .Select(item =&gt; new RoleViewModel(
                     item.WorkRoleId,
                      item.RoleName,
                      item.RoleDescription,
                      item.CompanyId,
                      item.WRUDId,
                      item.UserDetailsId,
                      item.FocusStart,
                      item.FocusEnd));
  </code></pre>
  
  <p>But, sadly, what this got mew wasn't a list og <code>RoleViewModel</code>s. Here's a copy from the value part in the debugger : </p>
  
  <pre><code>{System.Linq.Enumerable.WhereSelectListIterator&lt;&lt;&gt;f__AnonymousType6&lt;int, string, string, int, int, string, System.DateTime, System.DateTime&gt;, eksp.Models.RoleViewModel&gt;}
  </code></pre>