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:
I first created the rank variable that should hold the rank values.
I then added the rank variable within the body of my modifiedData variable (4th line from the bottom).
Code:
var rank = data.GroupBy(a => new
{
a.AppNumber
}).SelectMany(a => a.OrderBy(x => x.AppNumber)
.Select((x, i) => new { a.Key, Item = x, Rank = i + 1 }));
var modifiedData = data.Select(a =>
new
{
a.AppNumber,
a.Hrdbid,
ApplicationType = a.ApplicationType.Label,
a.ApplicationTypeId,
ActivityPhase = a.ApplicationActivityPhas
.Where(aap => aap.ActivityPhas.WorkFlowStep == a.ApplicationActivityPhas.Max(x => x.ActivityPhas.WorkFlowStep))
.Select(aap => aap.ActivityPhas.ActivityPhase),
ActivityPhaseDate = a.ApplicationActivityPhas
.Where(aap => aap.ActivityPhas.WorkFlowStep == a.ApplicationActivityPhas.Max(x => x.ActivityPhas.WorkFlowStep))
.Select(aap => aap.ActivityPhaseDate),
Address = a.Addresses.Where(x => x.AddressType == "Physical").Select(x => x.Address_),
rank,
Client = a.ApplicationClients.Where(ac => ac.HeadOfHousehold).Select(ac => ac.Client.LastName + ", " + ac.Client.FirstName),
a.Id
}).Where(a => a.ActivityPhase.Count() == 1 && a.ActivityPhase.Contains("Waiting"));
Then in my jQuery datatable, I call/reference the column as { data: "Rank" }
Note that data
is equal to var data = _db.Applications.AsQueryable();
I am not sure if I am missing a NuGet package or something else.