<?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 : Entity exists when adding</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Entity exists when adding</description>
  <pubDate>Sun, 12 Apr 2026 20:29:57 -700</pubDate>
  <lastBuildDate>Mon, 20 Jun 2011 22:21:31 -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=2771</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>Entity exists when adding :   Hi KimOkay totally my problem....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2771&amp;PID=11045#11045</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=770" rel="nofollow">GeorgeB</a><br /><strong>Subject:</strong> 2771<br /><strong>Posted:</strong> 20-Jun-2011 at 10:21pm<br /><br />Hi Kim<div>&nbsp;</div><div>Okay totally my problem. </div><div>&nbsp;</div><div>When testing with single a record coming in everything worked but when multiple records were coming in (and they could be duplicated), I was doing an async check to see&nbsp;if the record already existed, it was possible in some cases for me to be adding a new record whilst still waiting for the first check to come back.</div><div>&nbsp;</div><div>My system is a lot more complex that what I have described above, but that is the big picture.</div><div>&nbsp;</div><div>Thanks for the help.</div><div>&nbsp;</div><div>Kr</div><div>George</div>]]>
   </description>
   <pubDate>Mon, 20 Jun 2011 22:21:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2771&amp;PID=11045#11045</guid>
  </item> 
  <item>
   <title>Entity exists when adding :   Hi George,The EntityManager...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2771&amp;PID=11008#11008</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> 2771<br /><strong>Posted:</strong> 16-Jun-2011 at 5:18pm<br /><br />Hi George,<div>&nbsp;</div><div>The EntityManager is not designed to be thread safe, so if you are finding that the CreateTrackingEvent can be called simultaneously from two separate threads then you should lock around the logic in the method.&nbsp; Eg,</div><div>&nbsp;</div><div>lock (_aLockObject) {</div><div>&nbsp; ... create and add entity</div><div>}</div><div>&nbsp;</div><div>If that doesn't fix the problem, then it's not a threading issue and we'll need to get more information on what's going on within the application.</div><div>&nbsp;</div><div>&nbsp;</div>]]>
   </description>
   <pubDate>Thu, 16 Jun 2011 17:18:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2771&amp;PID=11008#11008</guid>
  </item> 
  <item>
   <title>Entity exists when adding : Hi  I&amp;#039;m using DevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2771&amp;PID=10999#10999</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=770" rel="nofollow">GeorgeB</a><br /><strong>Subject:</strong> 2771<br /><strong>Posted:</strong> 16-Jun-2011 at 11:09am<br /><br /><DIV>Hi</DIV><DIV>&nbsp;</DIV><DIV>I'm using DevForce 6.1 with Silverlight.</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV>I have a single instance of&nbsp;EntityManager. I create a new entity, add it to the manager and in some instances I get this error:-</DIV><DIV>&nbsp;</DIV><DIV></DIV><strong>An entity with this key: TrackingEvent: -100 already exists in this EntityManager</strong><DIV>&nbsp;</DIV><DIV>In my repository I have (nothing really fancy - I'm using INT in SQL Server as a IdentityColumn)</DIV><DIV><PRE style="FONT-FAMILY: C&#111;nsolas; : white; COLOR: black; FONT-SIZE: 13px">&nbsp;<SPAN style="COLOR: blue">public</SPAN>&nbsp;<SPAN style="COLOR: #2b91af">TrackingEvent</SPAN>&nbsp;CreateTrackingEvent()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">var</SPAN>&nbsp;aTrackingEvent&nbsp;=&nbsp;Manager.CreateEntity&lt;<SPAN style="COLOR: #2b91af">TrackingEvent</SPAN>&gt;();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager.GenerateId(aTrackingEvent,&nbsp;<SPAN style="COLOR: #2b91af">TrackingEvent</SPAN>.<SPAN style="COLOR: #2b91af">PropertyMetadata</SPAN>.TrackingEventID);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Manager.AddEntity(aTrackingEvent);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: blue">return</SPAN>&nbsp;aTrackingEvent;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</PRE><PRE style="FONT-FAMILY: C&#111;nsolas; : white; COLOR: black; FONT-SIZE: 13px">Once I've assigned values to all the fields, I do a SaveAsync().</PRE><PRE style="FONT-FAMILY: C&#111;nsolas; : white; COLOR: black; FONT-SIZE: 13px">It's possible that the CreateTrackingEvent may get called at the same time but I can't stop that (nature of the application). </PRE><PRE style="FONT-FAMILY: C&#111;nsolas; : white; COLOR: black; FONT-SIZE: 13px">Surely between the GenerateId and AddEntity, the EM can keep the ID's unique? </PRE><PRE style="FONT-FAMILY: C&#111;nsolas; : white; COLOR: black; FONT-SIZE: 13px">Do I need create my own IdGenerator?</PRE><PRE style="FONT-FAMILY: C&#111;nsolas; : white; COLOR: black; FONT-SIZE: 13px">Thanks</PRE><PRE style="FONT-FAMILY: C&#111;nsolas; : white; COLOR: black; FONT-SIZE: 13px">George</PRE></DIV>]]>
   </description>
   <pubDate>Thu, 16 Jun 2011 11:09:12 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2771&amp;PID=10999#10999</guid>
  </item> 
 </channel>
</rss>