title: Return class as JSON with one extra field in API using Entity Framework
body: <p>I have a class <code>Employee</code> with many properties in it and when I want to read it from the database and return a list of it. I want to add an extra field to it.</p>
  
  <p>Currently it's like this:</p>
  
  <pre><code>return await _context.Employees.ToListAsync();
  </code></pre>
  
  <p>I don't want to use <code>Select</code> command after <code>Employee</code> because as far as I know I have to list all my properties in the <code>Employee</code> class to be able to add an extra one like below:</p>
  
  <pre><code>return await _context.Employees.Select(em =&gt; new 
  {
     em.Firstname, // In employee class
     em.Lastname, // In employee class
     ... // Other properties in employee class
     EXTRAFIELD = "Data" // Extra field with any data I want to add to employee
  }).ToListAsync();
  </code></pre>
  
  <p>But in the solution above I have to list all my fields in employee class.</p>
  
  <p>I don't want to do as below as it puts employee in a new object names em:</p>
  
  <pre><code>return await _context.Employees.Select(em =&gt; new 
      {
         em,
         EXTRAFIELD = "Data" // Extra field with any data I want to add to employee
      }).ToListAsync();
  </code></pre>
  
  <p>Is there a way to tell <code>DbContext</code> (<code>_context</code>) to return <code>Employee</code> fields and add "this new field" in it (create new object which has same properties as <code>Employee</code> with one extra)?</p>