<?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 : EntityManager.HasChanges() and  CheckpointManager.RollbackCheckpoints()</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : EntityManager.HasChanges() and  CheckpointManager.RollbackCheckpoints()</description>
  <pubDate>Tue, 28 Apr 2026 03:25:31 -700</pubDate>
  <lastBuildDate>Tue, 17 Mar 2009 14:14:23 -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=1076</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>EntityManager.HasChanges() and  CheckpointManager.RollbackCheckpoints() : Afrizal, this problem is due to...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=4098#4098</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1076<br /><strong>Posted:</strong> 17-Mar-2009 at 2:14pm<br /><br />Afrizal, this problem is due to the order in which the EntityKey is set and the entity is added to the EntityManager.&nbsp; Your entity creation methods all do something similar to this: <DIV>&nbsp;</DIV><DIV><FONT face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person newInstance = manager.CreateEntity&lt;Person&gt;();</FONT></DIV><DIV><FONT face="Courier New, Courier, mono">&nbsp;<FONT color=#990000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newInstance.EntityAspect.AddToManager();</FONT></FONT></DIV><DIV><FONT face="Courier New, Courier, mono" color=#990000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newInstance.InternalId = Guid.NewGuid();</FONT></DIV><DIV><FONT face="Courier New, Courier, mono"><FONT color=#990000>&nbsp;</FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ... set other properties</FONT></DIV><DIV>&nbsp;</DIV><DIV>When checkpointing is on the entity key needs to be set&nbsp;prior to adding the entity to cache, otherwise&nbsp;additions and&nbsp;modifications are not correctly tracked, with unpredictable results.&nbsp; You can easily fix the problem by following this pattern instead:</DIV><DIV>&nbsp;</DIV><DIV><DIV><FONT face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Person newInstance = manager.CreateEntity&lt;Person&gt;();</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" color=#cc0000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newInstance.InternalId = Guid.NewGuid();</FONT></DIV><DIV><DIV><FONT face="Courier New, Courier, mono" color=#cc0000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; newInstance.EntityAspect.AddToManager();</FONT></DIV></DIV><DIV><FONT face="Courier New, Courier, mono">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ... set other properties</FONT></DIV><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>]]>
   </description>
   <pubDate>Tue, 17 Mar 2009 14:14:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=4098#4098</guid>
  </item> 
  <item>
   <title>EntityManager.HasChanges() and  CheckpointManager.RollbackCheckpoints() : Afrizal, I&amp;#039;m still unable...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3932#3932</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1076<br /><strong>Posted:</strong> 24-Feb-2009 at 12:09pm<br /><br />Afrizal, I'm still unable to reproduce the problem in the 4.2.2.3 version.&nbsp; Following your steps with the NorthwindIB tutorial database and a Customer entity, I see that checkpoint/rollback is working as desired and rolls back all added entities.&nbsp; I really think there may be side effects in your Entity creation logic which are causing the problem.&nbsp; <DIV>&nbsp;</DIV><DIV>Please&nbsp;send a sample solution showing the problem to <a href="mailto:support@ideablade.com" target="_blank">support@ideablade.com</A>.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Tue, 24 Feb 2009 12:09:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3932#3932</guid>
  </item> 
  <item>
   <title>EntityManager.HasChanges() and  CheckpointManager.RollbackCheckpoints() : Hello Kim, Sorry for the late...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3931#3931</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=417" rel="nofollow">afrizal.chen</a><br /><strong>Subject:</strong> 1076<br /><strong>Posted:</strong> 22-Feb-2009 at 11:25pm<br /><br />Hello Kim, Sorry for the late reply.<br><br>I have new finding regarding this issue:<br>1. BeginCheckpoint()<br>2. Create 3 new Entities<br>3. <font color="#0000ff" size="2">var</font><font size="2"> list = em.FindEntities(</font><font color="#2b91af" size="2">EntityState</font><font size="2">.Added</font><font size="2">);</font> // "list.ToList().Count" returns "3"<br>4. RollbackCheckpoint()<br><font color="#0000ff" size="2">5. </font><font size="2">list = em.FindEntities(</font><font color="#2b91af" size="2">EntityState</font><font size="2">.Added</font><font size="2">);</font> // "list.ToList().Count" returns "2"&nbsp; now<br><br>if I create 2 new Entities in step (2), the 'list.ToList().Count' will return me '1' after rollingback.<br>It seems that the RollBack is only rolling back 1 entity.<br>by the way I am using "DevForce EF 4.2.2.3".<br><br>Thanks,<br>Afrizal<br>]]>
   </description>
   <pubDate>Sun, 22 Feb 2009 23:25:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3931#3931</guid>
  </item> 
  <item>
   <title>EntityManager.HasChanges() and  CheckpointManager.RollbackCheckpoints() : I&amp;#039;m not able to reproduce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3865#3865</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1076<br /><strong>Posted:</strong> 04-Feb-2009 at 11:15am<br /><br />I'm not able to reproduce the problem.&nbsp; Here's the test I'm using, against the tutorial DB: <DIV><FONT color=#2b91af size=2></FONT>&nbsp;</DIV><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><DIV><FONT color=#2b91af size=2>DomainModelEntityManager</FONT><FONT size=2> em = </FONT><FONT color=#2b91af size=2>DomainModelEntityManager</FONT><FONT size=2>.DefaultManager;</DIV></BLOCKQUOTE><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><DIV></FONT><FONT color=#2b91af size=2>Assert</FONT><FONT size=2>.IsFalse(em.HasChanges());</FONT></DIV><DIV><FONT size=2>em.CheckpointManager.BeginCheckpoint();</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT color=#2b91af size=2>Customer</FONT><FONT size=2> aCustomer = em.CreateEntity&lt;</FONT><FONT color=#2b91af size=2>Customer</FONT><FONT size=2>&gt;();</FONT></DIV><DIV><FONT size=2>em.GenerateId(aCustomer, </FONT><FONT color=#2b91af size=2>Customer</FONT><FONT size=2>.IdEntityProperty);</FONT></DIV><DIV><FONT size=2>aCustomer.CompanyName = </FONT><FONT color=#a31515 size=2>"My new company"</FONT><FONT size=2>;</FONT></DIV><DIV><FONT size=2>em.AddEntity(aCustomer);</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT color=#2b91af size=2>Assert</FONT><FONT size=2>.IsTrue(em.HasChanges());</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>em.CheckpointManager.RollbackCheckpoint();</FONT></DIV><DIV><FONT color=#2b91af size=2>Assert</FONT><FONT size=2>.IsFalse(em.CheckpointManager.IsCheckpointing);</FONT></DIV><DIV><FONT color=#2b91af size=2>Assert</FONT><FONT size=2>.IsFalse(em.HasChanges());</FONT></DIV></BLOCKQUOTE><DIV>We haven't specifically fixed any checkpointing issues in current bits, but it's possible you're seeing a problem in your version which has been fixed by other changes.&nbsp; Which version of DevForce EF are you using?</DIV><DIV>&nbsp;</DIV><DIV>It's also possible that there are some side effects with your specific Entity creation that I don't see with the tutorial entities.&nbsp; Try this - after determining that the EntityManager is incorrectly reporting changes, query for changed entities, like this:</DIV><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><DIV><FONT color=#0000ff size=2><P>var</FONT><FONT size=2> list = em.FindEntities(</FONT><FONT color=#2b91af size=2>EntityState</FONT><FONT size=2>.Added | </FONT><FONT color=#2b91af size=2>EntityState</FONT><FONT size=2>.Deleted | </FONT><FONT color=#2b91af size=2>EntityState</FONT><FONT size=2>.Modified);</P></DIV></BLOCKQUOTE><DIV dir=ltr></FONT><FONT size=2>This may help&nbsp;us diagnose the problem.&nbsp;</DIV></FONT>]]>
   </description>
   <pubDate>Wed, 04 Feb 2009 11:15:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3865#3865</guid>
  </item> 
  <item>
   <title>EntityManager.HasChanges() and  CheckpointManager.RollbackCheckpoints() : Current State:EntityManager.HasChanges()...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3851#3851</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=417" rel="nofollow">afrizal.chen</a><br /><strong>Subject:</strong> 1076<br /><strong>Posted:</strong> 02-Feb-2009 at 3:42am<br /><br />Current State:<br>EntityManager.HasChanges() ==&gt; false<br><br>This is the scenario:<br>1. CheckpointManager.BeginCheckPoint()<br>2. Create a new Entity. Here, EntityManager.HasChanges() ==&gt; true<br>3. CheckpointManager.RollbackCheckpoints(). Here, CheckpointManager.IsCheckPointing == &gt; false<br><br>Actual Result:<br>EntityManager.HasChanges() ==&gt; true<br><br>My Expected Result:<br>EntityManager.HasChanges() ==&gt; false<br><br>My Issue:<br>I don't know if this behavior is by designed. But I hope there's a way to get my expected result, please advise. :)<br><br>Thank you.<br>]]>
   </description>
   <pubDate>Mon, 02 Feb 2009 03:42:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1076&amp;PID=3851#3851</guid>
  </item> 
 </channel>
</rss>