Linq Grouping by 2 keys as a one

Posted by Evgeny on Stack Overflow See other posts from Stack Overflow or by Evgeny
Published on 2010-04-01T18:07:00Z Indexed on 2010/04/02 11:43 UTC
Read the original article Hit count: 356

Filed under:
|
|

Hello! I write a simple OLAP viewer for my web-site. Here are the classes (abstract example):

Employee
{
       ID;
       Name;
       Roles[]; //What Employee can do
}
Order
{
    Price;
    Employee Manager;
    Employee Executive; //Maybe wrong english. The person which perform order         
}

Employee can be Manager and Executive in the order at the same time. This means that Employee role is not fixed. I have to group orders by employees and finally get IGrouping with Employee key.

So .GroupBy(el=>new {el.Manager,el.Executive}) is not allowed.

I considered some tricks with IEqualityComparable, but found no solution.

If somrbody will help I'll be vary glad, thank you.

© Stack Overflow or respective owner

Related posts about linq-to-entities

Related posts about grouping