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