<?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 : ConcurrencyConflicts Learning Resources</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : ConcurrencyConflicts Learning Resources</description>
  <pubDate>Sat, 11 Apr 2026 15:31:31 -700</pubDate>
  <lastBuildDate>Thu, 04 Mar 2010 19:30:38 -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=1667</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>ConcurrencyConflicts Learning Resources : Will inform my colleague, Viola,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1667&amp;PID=6301#6301</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=370" rel="nofollow">sebma</a><br /><strong>Subject:</strong> 1667<br /><strong>Posted:</strong> 04-Mar-2010 at 7:30pm<br /><br />Will inform my colleague, Viola, who caught this, not me ;-)<br /><br />Thanks much.]]>
   </description>
   <pubDate>Thu, 04 Mar 2010 19:30:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1667&amp;PID=6301#6301</guid>
  </item> 
  <item>
   <title>ConcurrencyConflicts Learning Resources : Hey, good catch, Sebastian! Looks...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1667&amp;PID=6300#6300</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 1667<br /><strong>Posted:</strong> 04-Mar-2010 at 6:42pm<br /><br />Hey, good catch, Sebastian! Looks like that little critter has been in there for a while.<br><br>Each of the saves, including the one in step 3, does update the RowVersion value in the database. But when the save doesn't go through because of a concurrency conflict, and you then elect to force your local changes through, we make that possible by jury rigging the entity so it thinks it's not in conflict with the version in the database.<br><br>That we do with this call to <i>RefetchEntity</i> in method <i>ResolveMyConflicts</i>():<br><font color="#0000ff"><br>&nbsp;&nbsp; pEntityManager.RefetchEntity(pEntityWithError, MergeStrategy.PreserveChangesUpdateOriginal);</font><br><br>The idea there is that we'll leave <i>EntityVersion.Current </i>for the entity as is (so your local changes remain in place), but update <i>EntityVersion.Original </i>to the same set of values that currently exist  in the database for the entity in question. That way, when we resubmit the entity for saving, the concurrency engine won't see a conflict anymore (between the value of RowVersion that it finds in the database and the <i>EntityVersion.Original </i>value in the entity).&nbsp; <br><br>The problem is that, because we're only updating the <i>original </i>values from the database, the <i>current </i>value for RowVersion is now actually <i>1 behind </i>its value in the database. So when the save increments it by 1, it ends up being exactly equal to the value currently in the database. The save goes through, and the RowVersion value is updated in the database, but it is updated to the same value it had before. So then the next save doesn't realize the record got changed in the period since it was retrieved.<br><br>The fix is to include the following code right after the above-referenced call to RefetchEntity():<br><font color="#0000ff"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Set the Current values of the concurrency columns to what we just<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // got from the database in our call to RefetchEntity(). We want them to<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // enter the Save in the same state they would if we had retrieved the <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // entity from the database in the state it has there now and THEN made<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // our changes.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityMetadata instanceMetadata = pEntityWithError.EntityAspect.EntityMetadata;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (DataEntityProperty property in instanceMetadata.ConcurrencyProperties) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; property.SetValue(pEntityWithError,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (pEntityWithError as BaseEntity).GetRawPropertyValue(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; property, EntityVersion.Original));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br></font><br>]]>
   </description>
   <pubDate>Thu, 04 Mar 2010 18:42:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1667&amp;PID=6300#6300</guid>
  </item> 
  <item>
   <title>ConcurrencyConflicts Learning Resources :   Not sure if anyone encountered...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1667&amp;PID=6278#6278</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=370" rel="nofollow">sebma</a><br /><strong>Subject:</strong> 1667<br /><strong>Posted:</strong> 02-Mar-2010 at 10:16pm<br /><br /><DIV></DIV><DIV><SPAN lang=""><P>Not sure if anyone encountered this from the Learning Resources Sample for ConcurrencyConflicts.</P><DIV>We found Concurrency Conflicts are not handled from the following issue steps:</DIV><DIV>&nbsp;</DIV><DIV>0. Use sample code @..\IdeaBlade DevForce\Learning Resources\040_BusObjPersistence\ConcurrencyConflicts\Samples\300WNF_WinForms\CodeCS\UI\ConcurrencyHandler.cs</DIV><DIV>&nbsp;</DIV><DIV>1. Call ResolveMyConflicts(...) to resolve conflicts </DIV><DIV>&nbsp;</DIV><DIV>2. Modify a field (e.g. employee-&gt; firstname) in app1, save, "Save Succeeded".</DIV><P>3. Update the same field in app2, save, a messagebox of the detailed conflicts will be shown, choose to save own copy, "Save Succeeded"</P><DIV>4. Then update the same field again in app1. No warning about conflicts, end up with "Save Succeeded" again.</DIV><DIV>&nbsp;</DIV><DIV>Cause of problem: concurrency column(RowVersion) won't be updated by user2's SaveChanges()@step3. Which means @step4, app1 thinks its copy is the latest because of the RowVersion == the latest RowVersion in DB.</DIV><P>Is the above as designed?</P></SPAN></DIV><DIV>Thanks</DIV><DIV>Sebastian</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Tue, 02 Mar 2010 22:16:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1667&amp;PID=6278#6278</guid>
  </item> 
 </channel>
</rss>