title: ASP.NET Web Api join two tables to make an array of objects
body: <p>This might be already asked question but I still can't solve my problem. I don't even know if I am on the right path. Some help will be appreciated. </p>
  
  <p>I have two model classes in an ASP.NET Web API project looking like this:</p>
  
  <pre><code>namespace Artists.Models
  {
      public class Artist
      {
          public int ArtistID { get; set; }
          public string ArtistName { get; set; }
      }
  }
  </code></pre>
  
  <p>and : </p>
  
  <pre><code>namespace Artists.Models
  {
      public class Project
      {
          public int ProjectID { get; set; }
          public string ProjectName { get; set; }
          public int ArtistID { get; set; }
      }
  }
  </code></pre>
  
  <p>That created two SQL tables connected by <code>ArtistID</code> as a foreign key in <code>Project</code>.</p>
  
  <p>I have this controller code:</p>
  
  <pre><code>public IQueryable&lt;Object&gt; GetArtists()
  {
       return from a in db.Artists
              join p in db.Projects on a.ArtistID equals p.ArtistID
              select new
              {
                  account_name = a.ArtistName,
                  project_name = p.ProjectName
              };
  }
  </code></pre>
  
  <p>that returns this output in Postman:</p>
  
  <pre><code>[
      {
          "name": "Jack",
          "project_name": "ProjectOne"
      },
      {
          "name": "Mike",
          "project_name": "ProjectTwo"
      },
      {
          "name": "Mike",
          "project_name": "ProjectThree"
      },
      {
          "name": "John",
          "project_name": "ProjectFour"
      },
      {
          "name": "John",
          "project_name": "ProjectFive"
      }
  ]
  </code></pre>
  
  <p>but I want the output to be like this:</p>
  
  <pre><code>[
      {
          "name": "Jack",
          "projects": ["ProjectOne"]
      },
      {
          "name": "Mike",
          "projects": ["ProjectTwo", "ProjectThree"]
      },
      {
          "name": "John",
          "projects": ["ProjectFour", "ProjectFive"]
      },
  ]
  </code></pre>
  
  <p>Am I even close? I know this might an asked question but I really can't figure it out.</p>