我有两个不同类型的集合:
// First Collection
public class ObjectA
{
public IEnumerable<SomeObject> Persons { get; set; }
public IEnumerable<SomeOtherObject> Items { get; set; }
}
public class SomeObject
{
public string ID { get; set; }
}
public class SomeOtherObject
{
public string ID { get; set; }
}
// Second Collection (ID property holds unique values, PersonID and EntityID do not)
public class ObjectB
{
public string ID { get; set; }
public string PersonID { get; set; }
public string EntityID{ get; set; }
}
// Assuming the following entries...
var list1 = new ObjectA();
var persons = new List<SomeObject>();
persons.Add(new SomeObject() { ID = "A" });
persons.Add(new SomeObject() { ID = "B" });
persons.Add(new SomeObject() { ID = "C" });
list1.Persons = persons;
var items = new List<SomeOtherObject>();
items.Add(new SomeOtherObject() { ID = "1" });
items.Add(new SomeOtherObject() { ID = "2" });
list1.Items = items;
var list2 = new List<ObjectB>();
list2.Add(new ObjectB() { ID = "1", PersonID = "C", EntityID = "1" });
list2.Add(new ObjectB() { ID = "2", PersonID = "A", EntityID = "1" });
list2.Add(new ObjectB() { ID = "3", PersonID = "A", EntityID = "2" });
list2.Add(new ObjectB() { ID = "4", PersonID = "B", EntityID = "1" });
list2.Add(new ObjectB() { ID = "5", PersonID = "B", EntityID = "2" });
给定这两个列表(list1 和 list2)。如何在 list2 中查找 PersonID = A AND B AND EntityID = 1 AND 2 的项目
换句话说,必须满足所有条件,所以“人 C”不会成功,因为他们只有 EntityID =“1”,而不是“1”和“2”