void UpdateCollection(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { switch (e.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: { if (e.NewItems != null && e.NewItems.Count > 0) { foreach (AuswahlEintraege item in e.NewItems) { if (fk.Where(k => k.id_FirmaEigenschaft == item.id).Count() == 0) { var k = new SI_SelectedTypFirmaEigenschaften(); k.id_FirmaEigenschaft = item.id; fk.Add(k); db.AddToSI_SelectedTypFirmaEigenschaften(k); db.SaveChanges(); } } } break; } case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: { if (e.OldItems != null && e.OldItems.Count > 0) { foreach (AuswahlEintraege item in e.OldItems) { if (fk.Where(k => k.id_FirmaEigenschaft == item.id).Count() == 1) { var k = fk.Where(ka => ka.id_FirmaEigenschaft == item.id).SingleOrDefault(); fk.Remove(k); db.DeleteObject(k); db.SaveChanges(); } } } break; } default: { break; } } }