Jak usunąć pozycję z listy za pomocą linq?.Usuń pozycję z listy używając linq
Mam listę przedmiotów i każdy przedmiot, który sam ma listę innych przedmiotów teraz chcę chaeck, jeśli inne elementy zawiera jakiekolwiek elementy z podanej listy, więc główny element powinien zostać usunięty. Proszę sprawdzić kod, aby uzyskać większą przejrzystość.
public Class BaseItems
{
public int ID { get; set; }
public List<IAppointment> Appointmerts { get; set; }
}
Public DeleteApp(List<IAppointment> appointmentsToCheck)
{
List<BaseItems> _lstBase ; // is having list of appointments
//now I want to remove all items from _lstBase which _lstBase.Appointmerts contains
any item of appointmentsToCheck (appointmentsToCheck item and BaseItems.Appointmerts
item is having a same reference)
//_lstBase.RemoveAll(a => a.Appointmerts.Contains(//any item from appointmentsToCheck));
}