title: The specified type member 'SubArea' is not supported in LINQ to Entities
body: <p>Getting the following error on GroupBy 2 separate fields.</p>
  <p>I have spent the past 2 days wondering why this is not working. I know I might be missing an obvious part, please help.</p>
  <pre><code>var res = db.Properties.GroupBy(x =&gt; x.AreaName)
                        .Select(x =&gt; new PropVM
                        {
                            AreaName = x.Key,
                            SubCount =x.Count()
                            
                        }).GroupBy(x =&gt; new { sub = x.SubArea})
                        .Select(x =&gt; new PropVM
                        {
                            SubArea = x.Key.sub
                        });
              
  
              return View(res);
  
  </code></pre>
  <p>View</p>
  <pre><code>&lt;h2&gt;Groupby&lt;/h2&gt;
  &lt;div class=&quot;row&quot;&gt;
      @foreach(var i in Model)
      {
      &lt;div class=&quot;col-sm-2&quot;&gt;
          &lt;p&gt;@i.AreaName&lt;/p&gt;
          &lt;p&gt;@i.SubArea&lt;/p&gt;
      &lt;/div&gt;
          
      }
  &lt;/div&gt;
  </code></pre>
  <p>Property Model Class</p>
  <pre><code>public string SubArea { get; set; }
  public int AreaId { get; set; }
  public string AreaName { get; set; }
  </code></pre>
  <p>PropVM Model Class</p>
  <pre><code>public string AreaName { get; set; }
  public string SubArea { get; set; }
  
  public string AreaSlug { get; set; }
  
  public string SubAreaSlug { get; set; }
  
  public int SubCount { get; set; }
  
  </code></pre>
  <p>With this Code it is working but the View is rendering in List format, instead of Side by Side. How to show view in SideBySide view?</p>
  <p>Working Action Method:</p>
  <pre><code> 
  
      var res = db.Properties
                  .GroupBy(r =&gt; new { r.AreaName, r.SubArea })
                  .OrderBy(g =&gt; g.Key.AreaName)
                  .Select(g =&gt; new PropVM { AreaName = g.Key.AreaName, SubArea = g.Key.SubArea, SubCount = g.Count() });
      
                  return View(res.ToList());
  </code></pre>
  <p>View is as follows</p>
  <pre><code>
      @{
          var area = string.Empty;
          foreach (var item in Model)
          {
              &lt;div class=&quot;col-sm-2&quot;&gt;
                  @if (item.AreaName != area)
                  {
                      &lt;p&gt;&lt;b&gt;@item.AreaName&lt;/b&gt;&lt;/p&gt;
                      area = item.AreaName;
                  }
                  &lt;p&gt;@item.SubArea  @item.SubCount&lt;/p&gt;
              &lt;/div&gt;
          }
      }
  
  </code></pre>
  <p>See the below image of how this should render on View.</p>
  <p><a href="https://i.stack.imgur.com/iHgw9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iHgw9.jpg" alt="ListView" /></a></p>