title: Web Api: Return JSON with EF Included Member Field Count but not Member Object Data
body: <p>Scenario: Complaint object can have many Votes. In the GET request for All Complaints, I want to return the Vote Count, and not each individual vote object with the Complaint in the API response.</p>
  
  <p>Here's the main classes:</p>
  
  <pre><code>//Model: Complaint.cs
  public class Complaint
  {
      public int Id { get; set; }
      public string Summary { get; set; }
      public List&lt;Vote&gt; Votes { get; set; }
      public int UpVoteCount=&gt; Votes.Count(v =&gt; v.IsUpvote);
      public ApplicationUser Creator { get; set; }
  }
  
  
  //Model: Vote.cs
  public class Vote
  {
      public int Id { get; set; }
      public bool IsUpVote{ get; set; }
      public Complaint Complaint { get; set; }
      public ApplicationUser Creator { get; set; }
  }
  
  
  //DbContext: AppDbContext.cs
  ....
  public IQueryable&lt;Complaint&gt; ComplaintsWithData =&gt;
          Complaint
              .Include(complaint =&gt; complaint.Votes)
              .AsNoTracking();
  
  //ApiController: ComplaintsController.cs
  [HttpGet]
  public IEnumerable&lt;Complaint&gt; GetComplaints()
  {
        return _context.ComplaintsWithData.ToList();
  }
  </code></pre>
  
  <p>In the current JSON response, I get the Vote count, however I also get each individual vote object's details as well (which I don't need in this call).</p>
  
  <p><strong>Current Response:</strong></p>
  
  <pre><code>{
          "id": 2,
          "summary": "House was Stolen",
          "votes": [
              {
                  "id": 146,
                  "isUpvote": false,
                  "creator": null
              },
                          {
                  "id": 147,
                  "isUpvote": false,
                  "creator": null
              },
              ....
              ....
              ....
          ],
          "upVoteCount": 211,
      }
  </code></pre>
  
  <p><strong>Desired Response:</strong></p>
  
  <pre><code>{
          "id": 2,
          "summary": "House was Stolen",
          "upVoteCount": 211,
      }
  </code></pre>
  
  <p>I need to have the .Include(complaint => complaint.Votes) in the AppDbContext.cs file so that I can actually load the Votes to determine the Vote Count.</p>
  
  <p>I do not want to store the Vote count as an actual database column.</p>
  
  <p>Any advice would be greatly appreciated! </p>
  
  <p>I am using .NET Core 2.0 Web API with Entity Framework Core.</p>
  
  <p>Thanks in advance.</p>