title: How do i use a LINQ Results set to get a group by Count and show it with Viewdata on mvc razor page
body: <p>I am trying to create a couple of bootstrap cards that show the count of the number of tickets at a status. However i am struggling to get the data from the results query into a viewdata.  I have other drop downs ect that work via similar methods (viewbags).  </p>
  
  <p>The page is just showing a blank for the variable, like it does not exist.</p>
  
  <pre><code>public void CountofType(IQueryable&lt;Tickets&gt; _Tickets)
      {
  
          var CountType = _Tickets
              .GroupBy(T =&gt; new { T.Type })
                  .Select(group =&gt; new 
                  {
                      Text = group.First().Type,
                      //Value = group.First().Type.Count()
                      Value = group.Count()
                  }
                  );
          ViewBag.CountType = CountType;
  
          ViewData["CountTypeOPEN"] = CountType.FirstOrDefault(T =&gt; T.Text == "OPEN" );
  
          ViewData["CountTypeCLOSED"] = CountType.FirstOrDefault(X =&gt; X.Text == "CLOSED");
  
          ViewData["CountTypeOTHER"] = CountType.FirstOrDefault(Y =&gt; Y.Text != "OPEN"
                                                                       || Y.Text != "CLOSED");
  
      }`
  </code></pre>
  
  <p>The HTML card will look something like this:</p>
  
  <pre><code> &lt;div class="card-deck"&gt;
  
              &lt;div class="card text-white mb-3 bg-primary" style="max-width: 18rem; max-height: 7rem;&gt;
                  &lt;a href=@Url.Action("index", new { Statuses = "OPEN" }) class="btn btn-fix text-left"&gt;
                      &lt;div&gt;
                          &lt;h1 class="card-title text-white text-center"&gt;@ViewData["CountTypeOPEN"] &lt;/h1&gt;
  &lt;h5 class="card-title text-white text-center"&gt;Open Tickets&lt;/h5&gt;
                      &lt;/div&gt;
                  &lt;/a&gt;
              &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>