Ich würde annehmen, es gibt eine einfache LINQ-Abfrage, dies zu tun, ich bin nur nicht genau sicher, wie.
Bei diesem Stück Code:
class Program
{
static void Main(string[] args)
{
List<Person> peopleList1 = new List<Person>();
peopleList1.Add(new Person() { ID = 1 });
peopleList1.Add(new Person() { ID = 2 });
peopleList1.Add(new Person() { ID = 3 });
List<Person> peopleList2 = new List<Person>();
peopleList2.Add(new Person() { ID = 1 });
peopleList2.Add(new Person() { ID = 2 });
peopleList2.Add(new Person() { ID = 3 });
peopleList2.Add(new Person() { ID = 4 });
peopleList2.Add(new Person() { ID = 5 });
}
}
class Person
{
public int ID { get; set; }
}
Ich möchte eine LINQ-Abfrage ausführen, um mir alle Personen in peopleList2
die sich nicht in peopleList1
.
Dieses Beispiel sollte mir zwei Personen liefern (ID = 4 & ID = 5)