views:

517

answers:

2

I have written a little program that deletes a record from the database using the RIA Data Services (Silverlight) and I am using a datagrid to view my entity.

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 the SubmitChanges() the record is removed from the grid but then reappears on the grid. It comes back to the grid with an "EntityState = New".

When I query the database, the record is gone. So, why is the entity not removing the record?

Where do the zombies come from?

+1  A: 

According to this forum post, this might actually be a bug in RIA Services.

http://betaforums.silverlight.net/forums/t/112232.aspx

I suppose you could probably just refresh the page as a workaround?

thepaulpage
+1  A: 

According to this forum post, this might actually be a bug in RIA Services.

Thanks tehp. In light of this I was able to find a work around that did not involve refreshing the page. After I submit the changes I refresh the grid by repassing it my person object and the zombies are gone.

theDataGrid.ItemsSource = null;
   theDataGrid.ItemsSource = _PersonService.persons;
johnnywhoop