title: Display table with category name in one column and list of items belonging to category in second column with links on Details View in ASP.NET MVC View
body: <p>I my ASP.NET MVC Core 3.1 app I have Model that stores professions which looks like this:</p>
  <pre><code>public partial class Professions
  {
      public int ProfessionID { get; set; }
      public int? ProfessionGroupID { get; set; }
      public string ProfessionTitle { get; set; }
      public string ProfessionDescription { get; set; }
  }
  </code></pre>
  <p>So each profession belongs to some group of professions, therefore Model for profession groups looks like this:</p>
  <pre><code>public partial class ProfessionGroups
  {
      public ProfessionGroups()
      {
          Professions = new HashSet&lt;Professions&gt;();
      }
  
      public int ProfessionGroupID { get; set; }
      public int ProfessionGroupTitle { get; set; }
      public string ProfessionGroupDescription { get; set; }
  
      public virtual ICollection&lt;Professions&gt; Professions { get; set; }
  }
  </code></pre>
  <p>How can I display list of groups of professions in one columns and list of professions in another column
  with links which leads to each profession <code>Details</code> View?
  This is how output table in some <code>View</code> should look:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ProfessionGroups</th>
  <th>Professions</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Physiotherapy</td>
  <td><a href="http://.." rel="nofollow noreferrer"> Graduated physiotherapist</a> <br> <a href="http://..." rel="nofollow noreferrer">Physiotherapist (bachelor degree)</a>  <br> <a href="http://.." rel="nofollow noreferrer">Physiotherapy technician</a></td>
  </tr>
  <tr>
  <td>Geology</td>
  <td><a href="http://.." rel="nofollow noreferrer">Geological technician</a> <br> <a href="http://.." rel="nofollow noreferrer">Geology engineer</a></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>So far I've created ViewModel that suppose to hold needed data:</p>
  <pre><code>public class ProfGroupsVM
  {
      public int ProfessionGroupID { get; set; }
      public string ProfessionGroupTitle { get; set; }
      public List&lt;int&gt; ProfIDs { get; set; } = new List&lt;int&gt;();
      public List&lt;string&gt; ProfTitles { get; set; } = new List&lt;string&gt;();
  
  }   
  </code></pre>
  <p>For each <code>ProfessionGroupID</code> it has to populate <code>ProfIDs</code> with list of professions belonging to that group and <code>ProfTitles</code> should hold professions titles.</p>
  <p>So in Controller so far I have:</p>
  <pre><code>   var profGroupsVM= new ProfGroupsVM();
  
     var result = from p in _context.Professions
          group p.ProfessionID by p.ProfessionGroupID into g
                  select new  { ProfessionGroupID = g.Key, ProfessionIDs= g.ToList() };
  </code></pre>
  <p>I don't know how to assign this result back to my <code>ViewModel</code> nor how to display desired <code>View</code>.</p>