private void OnDeletePhone() { if (this.Entity.CustomerPhoneCollection != null && this.Entity.CustomerPhoneCollection.Any(x => x.IsSelected)) { var qureyItems = this.Entity.CustomerPhoneCollection.Where(x => x.IsSelected && (x.ID.HasValue && x.ID.Value > 0) && !x.IsDeleted).ToList(); if (qureyItems.Any()) { CustomerAction.DeleteCustomerPhones(this.DBConnectionString, qureyItems); qureyItems.ForEach(x => x.IsDeleted = true); } var items = this.Entity.CustomerPhoneCollection.Where(x => x.IsSelected && (!x.ID.HasValue || x.ID.Value <= 0)).ToList(); if (items.Any()) { foreach (var customerPhone in items) { this.Entity.CustomerPhoneCollection.Remove(customerPhone); } var tempCollection = new CustomerPhoneCollection(this.Entity.CustomerPhoneCollection.ToList()); this.Entity.CustomerPhoneCollection = null; this.Entity.CustomerPhoneCollection = tempCollection.InternalList; this.Entity.NotifyPropertyChanged("CustomerPhoneCollection"); } } }