Let me start by saying I've read these questions: 1 & 2, and I understand that I can write the code to find duplicates in my List, but my problem is I want to update the original list not just query and print the duplicates.
I know I can't update the collection the query returns as it's not a view, it's an anonymous type IEnumerable<T>
.
I want to be able to find duplicates in my list, and mark a property I've created called State
which is used later in the application.
Has anyone ran into this problem and can you point me in the right direction?
p.s. The approach I'm using ATM is a bubble sort type loop to go through the list item by item and compare key fields. Obviously this isn't the fastest method.
EDIT:
In order to consider an item in the list a "duplicate", there are three fields which must match. We'll call them Field1, Field2, and Field3
I have an overloaded Equals() method on the base class which compares these fields.
The only time I skip an object in my MarkDuplicates()
method is if the objects state is UNKNOWN
or ERROR
, otherwise, I test it.
Let me know if you need more details.
Thanks again!