I'm having a logic problem trying to return a collection of objects from a collection where the PersonId is contained in the personId of the first object.
This sounds hideously complicated, but here it is:
//classes
public class MyClass
{
public List<int> People { get; set; }
}
//Code
List<MyClass> myClasses = new List<MyClass>()
{
new MyClass()
{
People = new List<int>()
{
1,
2
}
},
new MyClass()
{
People = new List<int>()
{
1
}
},
new MyClass()
{
People = new List<int>()
{
2
}
},
new MyClass()
{
People = new List<int>()
{
3,
4
}
},
new MyClass()
{
People = new List<int>()
{
4
}
}
};
Basically I would like to return all instances of MyClass where the People contains any of the integers of the people in the first instance of MyClass.
Once I've got them, I would then do some work on them, and then delete them from myClasses, and start again until I return an empty collection.
So, my first run would return the first three instances of MyClass. I'd do some work on them, and then delete them.
My second run would return the fourth and fifth (which, because the first three are deleted would be the first and second).
Is this possible? Am I looking at this the wrong way?
I thought that this would be a sort of 'ContainsAny' query.
Edit: Made a mistake, but it's fixed.