wegee2
asked on
Distinct List Items - Sort of
Given this dataset in a List<CustomItem>, where CustomItem = string Name, int Index, int FID, and a few other random fields:
From the above set, I would want these rows:
The LINQ .Distinct doesn't seem to be what I want. I think it's going to be some combinations of group by's and max and let's, but I'm kinda swimming in unfamiliar territory with this one.
Name Index FID Misc
user1 100 3 random
user1 200 3 random
user1 100 4 random
user1 200 4 random
user1 300 4 random
user20 100 2 random
user20 200 2 random
user20 300 2 random
user20 100 4 random
user20 200 4 random
user20 300 4 random
I want to extract objects that have the highest Index value, given where Name and FID are equal.From the above set, I would want these rows:
Name Index FID Misc
user1 200 3 random
user1 300 4 random
user20 300 2 random
user20 300 4 random
I'm using a non-LINQ method now whereby I start with the first record and iterate through the list doing a manual comparison of line by line to see if I should add it to my resultset.The LINQ .Distinct doesn't seem to be what I want. I think it's going to be some combinations of group by's and max and let's, but I'm kinda swimming in unfamiliar territory with this one.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not a problem, glad to be of help. ;=)
ASKER
Spot on. Not only did that work, the results are lightning fast over a large list.
Thank you.