how do you create a distinct list from a dataitem list?
What is the syntax to remove duplicates from a dataitem list? I have tried this: list2 = list1.Distinct().ToList() list1 and list2 are defined as dataitem lists.
i do not get an error, but the list is not unique.
J
0
-
I did not come up with an inline answer, so I wrote a bunch of workflow logic around the issue.
So, I ended up checking for duplication as I populate the list while iterating a featureSet. I created a boolean variable set to true which will determine whether to add a given dataItem, then loop through the list itself(parallel foreach inside of a while which watches the boolean) and check the values of each dataItem in the list already against the new one made from a given feature. Matches set the boolean to false, ending the loop. The activity to insert the dataItem is within an if activity checking the boolean, so only non-dups get added.
If the list is already generated, the same logic will work but you'll need a new list of dataitems.
Would love to see a more elegant solution, this feels like unneeded code that could become problematic with large lists.0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar