'Is it possible to select items from IEnumerablle by two ids?

I have this piece of code that I usually use to update/delete/create items

HashSet<int> current = new HashSet<int>(diagram.Links.Select(lnk => lnk.IDInput);
HashSet<int> received = new HashSet<int>(d.Links.Select(lnk => lnk.IDInput));
IEnumerable<int> delete = current.Except(received);
IEnumerable<int> new = received.Except(current);

And it works perfect when my list works with one ID but it this case I want to do something like diagram.Links.Select(lnk => lnk.IDInput AND lnk.IDOutput) Is it even possible or should I use Where instead?

Thank you in advance



Solution 1:[1]

For not change the other logic in your code you can simply use Concat like this:

HashSet<int> current = new HashSet<int>(diagram.Links.Select(lnk => lnk.IDInput)
.Concat(diagram.Links.Select(lnk => lnk.IDOutput)));

HashSet<int> received = new HashSet<int>(d.Links.Select(lnk => lnk.IDInput)
.Concat(d.Links.Select(lnk => lnk.IDOutput)));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Saeed Esmaeelinejad