Deleting a record comes back from dead after submitting changes using RIA Data Services
I wrote a small program that deletes a record from a database using RIA Data Service (Silverlight) and I am using a datagrid to view my object.
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
DataContext _PersonService =
(DataContext)(personDataSource.DomainContext);
person removeThisPerson = (person)(dataGrid.SelectedItem);
// This removes it from the grid/entity
_PersonService.persons.Remove(removeThisPerson);
// This removes it from the database.
// After this it shows back up in the grid :(
personDataSource.SubmitChanges();
}
When I run SubmitChanges (), the entry is removed from the grid and then reappears in the grid. It goes back to the grid with "EntityState = New".
When I query the database, the entry disappears. So why isn't the object deleting the entry?
Where do zombies come from?
According to this forum post, this may actually be a bug in RIA Services.
Thanks tehp. In light of this, I was able to find work that did not include page refresh. After I submit the changes, I update the mesh, overloading it with my object and the zombies are gone.
theDataGrid.ItemsSource = null;
theDataGrid.ItemsSource = _PersonService.persons;
According to the post from this forum, this may actually be a bug in the RIA services.
http://betaforums.silverlight.net/forums/t/112232.aspx
I suppose you could just refresh the page as a workaround?
remove items like DomainDataSource.DataView.Remove (item) instead of removing from DomainContext