Note that there are some explanatory texts on larger screens.

plurals
  1. PODomainContext sometimes still HasChanges after SubmitChanges completes
    text
    copied!<p>I have a very simple server model that includes a parent entity with a [Composition] list of child entities. In my client, I have 2 functions. One function removes all the child entities from the parent and the other removes all and also edits a property on the parent entity.</p> <p>When I simply remove all child entities and SubmitChanges(), all is well.</p> <p>When I remove all child entities <em>and</em> edit the parent and SubmitChanges(), there are still pending changes (HasChanges == true) when the SubmitChanges() callback is fired.</p> <p>I am using Silveright 4 RTM and RIA Services 1.0 RTM.</p> <p>Any ideas what is going on here?</p> <p>Here are the server entities:</p> <pre><code>public class RegionDto { public RegionDto() { Cities = new List&lt;CityDto&gt;(); } [Key] public int Id { get; set; } public string Name { get; set; } [Include] [Composition] [Association("RegionDto_CityDto", "Id", "RegionId")] public List&lt;CityDto&gt; Cities { get; set; } } public class CityDto { [Key] public int Id { get; set; } public int RegionId { get; set; } public string Name { get; set; } } </code></pre> <p>And here is the client code:</p> <pre><code>public static class CState { private static RegionDomainContext _domainContext; public static RegionDomainContext DomainContext { get { if (_domainContext == null) { _domainContext = new RegionDomainContext(); } return _domainContext; } } public static void SaveChanges() { DomainContext.SubmitChanges(op =&gt; { if (DomainContext.HasChanges &amp;&amp; !DomainContext.IsSubmitting) { var w = new ChildWindow(); w.Content = "The DomainContext still has unsaved changes."; w.Show(); } }, null); } } public partial class MainPage : UserControl { private void ClearCitiesEditRegion(object sender, RoutedEventArgs e) { var region = (RegionDto)regionList.SelectedItem; if (region != null) { region.Name += "*"; while (region.Cities.Count &gt; 0) { region.Cities.Remove(region.Cities.First()); } CState.SaveChanges(); } } private void ClearCities(object sender, RoutedEventArgs e) { var region = (RegionDto)regionList.SelectedItem; if (region != null) { while (region.Cities.Count &gt; 0) { region.Cities.Remove(region.Cities.First()); } CState.SaveChanges(); } } } </code></pre> <p>When you run this code the ChildWindow is only shown when you the ClearCitiesEditRegion() method is called. The only difference between this and the ClearCities() method is the line where I edit the region.Name property.</p> <p>You can also download a sample project that reproduces this here: <a href="http://dl.dropbox.com/u/2393192/RIA_Services_Problem.zip" rel="noreferrer">http://dl.dropbox.com/u/2393192/RIA_Services_Problem.zip</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload