title: How to add this Rank Over Partition By in C#?
body: <p>I am trying to add a Rank Over Partition By as a table column. I am first starting with a simple example. However, I receive the following error message:</p>
  <p><a href="https://i.stack.imgur.com/deP3a.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/deP3a.jpg" alt="enter image description here" /></a></p>
  <p>I first created the rank variable that should hold the rank values.</p>
  <p>I then added the rank variable within the body of my modifiedData variable (4th line from the bottom).</p>
  <p>Code:</p>
  <pre class="lang-cs prettyprint-override"><code>    var rank = data.GroupBy(a =&gt; new
      {
          a.AppNumber
      }).SelectMany(a =&gt; a.OrderBy(x =&gt; x.AppNumber)
          .Select((x, i) =&gt; new { a.Key, Item = x, Rank = i + 1 }));
  
      var modifiedData = data.Select(a =&gt;
          new
          {
              a.AppNumber,
              a.Hrdbid,
              ApplicationType = a.ApplicationType.Label,
              a.ApplicationTypeId,
              ActivityPhase = a.ApplicationActivityPhas
                  .Where(aap =&gt; aap.ActivityPhas.WorkFlowStep == a.ApplicationActivityPhas.Max(x =&gt; x.ActivityPhas.WorkFlowStep))
                  .Select(aap =&gt; aap.ActivityPhas.ActivityPhase),
              ActivityPhaseDate = a.ApplicationActivityPhas
                  .Where(aap =&gt; aap.ActivityPhas.WorkFlowStep == a.ApplicationActivityPhas.Max(x =&gt; x.ActivityPhas.WorkFlowStep))
                  .Select(aap =&gt; aap.ActivityPhaseDate),
              Address = a.Addresses.Where(x =&gt; x.AddressType == &quot;Physical&quot;).Select(x =&gt; x.Address_),
              rank,
              Client = a.ApplicationClients.Where(ac =&gt; ac.HeadOfHousehold).Select(ac =&gt; ac.Client.LastName + &quot;, &quot; + ac.Client.FirstName),
              a.Id
          }).Where(a =&gt; a.ActivityPhase.Count() == 1 &amp;&amp; a.ActivityPhase.Contains(&quot;Waiting&quot;));
  </code></pre>
  <p>Then in my jQuery datatable, I call/reference the column as <code>{ data: &quot;Rank&quot; }</code></p>
  <p>Note that <code>data</code> is equal to <code>var data = _db.Applications.AsQueryable();</code></p>
  <p>I am not sure if I am missing a NuGet package or something else.</p>