I have an Applications table. An Application can have many ActivityPhases.
I use the following to display the latest ActivityPhase:
a.ApplicationActivityPhas.Where(aap => aap.ActivityPhas.WorkFlowStep == a.ApplicationActivityPhas.Max(x => x.ActivityPhas.WorkFlowStep)).Select(aap => aap.ActivityPhas.ActivityPhase)
Therefore, my Applications table only displays 1 ActivityPhase per Application record.
I have the following line that I am trying to use to order the ActivityPhase table column by:
data.OrderBy(a => a.ApplicationActivityPhas.FirstOrDefault().ActivityPhas.ActivityPhase);
The problem is that it is ordering the values within the ICollection. It does not order the values displayed in the Applications table.
First group by activity phase and select your maximum workflow step. Then select all the application phases that match this maximum workflow step.