0

I am trying to create a list of Queues that are displayed by Queue Category. Each Queue Category is assigned an Enum value as such.

    public enum QueueCategory
{
    None=0,
    Critical=1,
    High=2,
    Orphaned=3,
    Missing=4
}

And for each Category, I want to then display these fields.

    public class QueueInformation
{
    public string Name { get; set; }
    public Decimal PercentOfThreshold { get; set; }
    public string Host { get; set; }
    public DateTime OldestArrival { get; set; }
    public QueueCategory Category { get; set; }
}

}

How would I go about linking these two pages so that QueueInformation is displayed by QueueCategory?

2 Answers2

2
IEnumerable<QueueInformation> infos = ...;

foreach (var categoryGroup in infos.GroupBy(i => i.Category))
{
  Console.WriteLine("Current category: {0}", categoryGroup.Key);

  foreach (var queueInfo in categoryGroup)
  {
    Console.WriteLine(queueInfo.Name /*...*/);
  }

  Console.WriteLine("==========================");
}
Grozz
  • 8,317
  • 4
  • 38
  • 53
0

I assume you want a source ordered by the QueueCategory:

IEnumerable<QueueInformation> list = new BindingList<QueueInformation>();
var orderedList = from l in list orderby l.Category select l;

Hope this helps

shahar eldad
  • 861
  • 1
  • 12
  • 31