I'm new to LINQ, and I have trouble with a query I'm trying to write to teach myself LINQ.
I have a list of MyError objects. A MyError object has a errorcode (an enum) and an arraylist of MyEntryError objects. Some MyError may have the same errorcode.
I would like to create a LINQ query that take as input my list of MyError and outputs a new list of MyError so that, for each errorcode, there is only one MyError that will contain all the MyEntryError that failed with the errorcode of the MyError.
What I mean is let's say I have a list of MyError objects such as this one :
- MyError1 : errorcode = ErrorType1 Arraylist : A, C
- MyError2 : errorcode = ErrorType2 ArrayList : B, D, E
- MyError3 : errorcode = ErrorType2 ArrayList : F
- MyError4 : errorcode = ErrorType1 ArrayList : G
- MyError5 : errorcode = ErrorType3 ArrayList : Z
My desired output is a list of MyError objects with the following objects :
- MyError1 : errorcode = ErrorType1 ArrayList : A, C, G
- MyError2 : errorcode = ErrorType2 ArrayList : B, D, E, F
- MyError3 : errorcode = ErrorType3 ArrayList : Z
Is it possible with LINQ ? If so, How ?
I'm guessing that using an ArrayList instead of a List in the MyError class may be a problem so if it can't be done with an ArrayList, i would like to see a query that would works with a modified MyError class that uses a List
Thanks in advance