❔ Somewhat advanced check for ids in foreach, remove duplicated
Hi!
Right now im doing somewhat of a "complex" (at least for me to understand) check of id's to remove, and wanna ask if i can do this code example simpler, or shorter, cuz it feels like i could, but cant think of how
Since i tried to combine
Doesnt give the same result
Thanks in advance
15 Replies
that should work (not tested)
instead of all loops?
i don't even know what this does lol
what's
DoesIdExistInHigherHierachyModel
Basicly just returns true or false
Oh at the end it needs a. Any()
If there is a relation between an id and something in the higher stuff
This linq query get at first All ids from the one list and intersect them with the ids from the other list
Enumerable.Intersect Method (System.Linq)
Produces the set intersection of two sequences.
If there is any entry in both list Any() return true
I might explain this wrong
Or do u mean to replace all of the code with the linq
or just a part of the code?
All Code 😉
Since the string list itself wont have any similarity to the allids one
So it will never match
must be after i assume
Ohh I missed the one DoesItExists.... method
No worries
This will have to work for now lol
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.