Miguel Oz
asked on
LINQ group by enum and map to another enum
Dear Experts:
I need to group a list of customers (List<Customer>) where Customer contains this enum
to a new enum
Note: My initial code to map to the first enum:
var sortedDetails = _customers.GroupBy(x => x.CustomerType).ToDictiona ry(t => t.Key, t => t.ToList());
Your answer should return a dictionary mapped to the new enum.
Thanks
I need to group a list of customers (List<Customer>) where Customer contains this enum
public enum CustomerType
{
type1,
type2,
type3,
type4,
type5
}
to a new enum
public enum NewCustomerType
{
newtype1, //map to type1
newtype2, //map to type2 and 3
newtype3, //map to type4 and 5
}
Note: My initial code to map to the first enum:
var sortedDetails = _customers.GroupBy(x => x.CustomerType).ToDictiona
Your answer should return a dictionary mapped to the new enum.
Thanks
What is the point of this code? I get that you want to remap the customer type, but what is the purpose of the GroupBy?
ASKER
If you are refering to the initial code sample is just to show you an initial attempt,. My expectations is that your answer should provide me with a dictionary sorted by the new enum.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks