<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Problem with AcceptChanges() &amp; RejectChanges() in cache.</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2012 : Problem with AcceptChanges() &amp; RejectChanges() in cache.</description>
  <pubDate>Fri, 10 Apr 2026 20:45:55 -700</pubDate>
  <lastBuildDate>Sat, 04 Jan 2014 09:57:34 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=4633</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Problem with AcceptChanges() &amp; RejectChanges() in cache. : Hi,  Windows 8.1; DevForce 2012...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4633&amp;PID=17316#17316</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1552" rel="nofollow">zbig</a><br /><strong>Subject:</strong> 4633<br /><strong>Posted:</strong> 04-Jan-2014 at 9:57am<br /><br />Hi,<br /><br />Windows 8.1; DevForce 2012 7.2.2; EF 6.0.2.<br /><br />I'm testing Windows Store App.<br /><br />The scenario is quite simple and, I hope, quite common:<br />1. The user works with local data for some time (1-3 days), stores data in local file, then synchronizes the local cache with remote database (the cache is deserialized from file) . <br />2. The user adds, deletes and <strong>updates</strong> entities.<br />3. Sometimes the user makes some errors (validation errors for instance) and must <strong>reject</strong> changes (rejects still local changes). <br /><br />Please find attached a simple solution (VS 2013, no packages because of the size) which simulates the scenario (all necessary client side code exists in MainPage.xaml.cs class). There are only three entities: User, Role and UserRole (many to many relation). <br /><br />First I add two Users and two roles (assotiated with those users) into the Entity Manager. Then two lines of code:<br /><br /><strong>  await appTestEntityManager.ConnectAsync();</strong><br /><strong>  await appTestEntityManager.SaveChangesAsync();</strong> <br /><br />makes synchronization with remote database - database is created, data are stored, relations are OK. Everything works fine. <br /><br />Lets <strong>drop database</strong> to be sure, that there is no data there. <br /><br />When in above scenario following two lines are uncommented:<br /><br /><strong>  admin.Password = "bbb"; </strong><br /><strong>  ((IEntity)admin).EntityAspect.AcceptChanges(); </strong><br /><br />after executing <strong>.SaveChanges()</strong> method, Entity Manager throws an exception:<br /><br /><strong>The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.UserRole_dbo.User_UserId". The conflict occurred in database "AppTestDbContext", table "dbo.User", column 'UserId'</strong><br /><br />The same error will occur, when changes will be rejected.<br /><br />So the main question is: <strong>How to accept/reject changes of updated entity when user works with local cache only</strong>?<br /><br />Thanks in advance for any advice!<br /><br />Zbig<br /><br /><a href="uploads/1552/AppTest4.zip" target="_blank">AppTest4.zip</a>]]>
   </description>
   <pubDate>Sat, 04 Jan 2014 09:57:34 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4633&amp;PID=17316#17316</guid>
  </item> 
 </channel>
</rss>