How to remove from one list all the items in another?

后端 未结 2 976
耶瑟儿~
耶瑟儿~ 2021-01-25 12:27

I\'m reading a set of rows from a remote database, and a similar set from a local database, and then using RemoveAll to get rid of remote rows that are already present locally..

相关标签:
2条回答
  • 2021-01-25 13:23

    I'm trying to do this without visual studio, so I'm not sure if this will work, but I'd suppose you could do something along these lines if what you're trying to do is compare the Identifier:

        Remote_Events = (From r_evt In Remote_Events
                        Where Not ((From l_evt In Local_Events Select l_evt.Identifier).Contains(r_evt.Identifier))
                        Select r_evt).ToList
    

    I hope this helps and at least moves you in the right direction.

    0 讨论(0)
  • 2021-01-25 13:33

    One way is this:

        remote_events.RemoveAll(Function(e) local_events.Exists(Function(f) f.Identifier = e.Identifier))
    
    0 讨论(0)
提交回复
热议问题