<?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 : import Entities with EntityState.Added into a sandbox</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : import Entities with EntityState.Added into a sandbox</description>
  <pubDate>Mon, 13 Apr 2026 11:10:16 -700</pubDate>
  <lastBuildDate>Tue, 22 Mar 2011 16:39:22 -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=2574</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>import Entities with EntityState.Added into a sandbox : Hi bebe,   When you import entities...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2574&amp;PID=10252#10252</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2574<br /><strong>Posted:</strong> 22-Mar-2011 at 4:39pm<br /><br /><DIV>Hi bebe, </DIV><DIV>&nbsp;</DIV><DIV>When you import entities into an EntityManager, all the temporary IDs are reset. (after all, they are temporary. Also, there is a possibility that the EntityManager could have this temporary ID already associated with another entity)</DIV><DIV>&nbsp;</DIV><DIV>Is this situation, you&nbsp;should resolve the IDs before importing them into the sandbox.</DIV><DIV>&nbsp;</DIV><DIV>i.e. </DIV><DIV><FONT size=2 face="Courier New">_manager.ForceIdFixup();</FONT></DIV><DIV>&nbsp;</DIV><DIV>Also, I assume you would edit and/or save the entities in the sandbox and then import then back to your 'main' EntityManager. In this situation resolving the IDs is also important because when you import the entities back to the 'main' EntityManger, you will not have 'duplicate' entities (i.e. one with the resolved ID and EntityState.Unchanged and another with the temp ID and EntityState.Added)</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp; Silvio. </DIV>]]>
   </description>
   <pubDate>Tue, 22 Mar 2011 16:39:22 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2574&amp;PID=10252#10252</guid>
  </item> 
  <item>
   <title>import Entities with EntityState.Added into a sandbox : I&amp;#039;d like to show the user...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2574&amp;PID=10241#10241</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=678" rel="nofollow">bebe</a><br /><strong>Subject:</strong> 2574<br /><strong>Posted:</strong> 22-Mar-2011 at 3:12am<br /><br /><br>I'd like to show the user the consequences of his/her editing before applying it to the main context. So I import the entites in a seperate editing context and ask for confirmation. I got some problems when the entities are just created: they get a new ID in the sandbox.<br><br>Is it stupid to put newly created entities in a sandbox? Or am I doing something wrong (see&nbsp; code below) <span style="color: green;"><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font face="Courier New, Courier, mono" size="2">//create&nbsp;some&nbsp;new&nbsp;Entities&nbsp;'SubjectForm'</font></span><font face="Courier New, Courier, mono" size="2"><br></font><pre style="font-family: c&#111;nsolas;"><font face="Courier New, Courier, mono" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;sf1&nbsp;=&nbsp;<span style="color: rgb43, 145, 175;">SubjectForm</span>.Add(<span style="color: blue;">...);</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;sf2&nbsp;=&nbsp;<span style="color: rgb43, 145, 175;">SubjectForm</span>.Add(<span style="color: blue;">...);</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;sf3&nbsp;=&nbsp;<span style="color: rgb43, 145, 175;">SubjectForm</span>.Add(<span style="color: blue;">...);</span><br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;roots&nbsp;=&nbsp;<span style="color: blue;">new</span>&#091;&#093;&nbsp;{&nbsp;sf3&nbsp;};<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;spans&nbsp;=&nbsp;<span style="color: blue;">new</span>&#091;&#093;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: rgb43, 145, 175;">EntitySpan</span>(<span style="color: rgb43, 145, 175;">SubjectForm</span>.<span style="color: rgb43, 145, 175;">PropertyMetadata</span>.Form.RelationLink),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">new</span>&nbsp;<span style="color: rgb43, 145, 175;">EntitySpan</span>(<span style="color: rgb43, 145, 175;">SubjectForm</span>.<span style="color: rgb43, 145, 175;">PropertyMetadata</span>.Subject.RelationLink)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;};<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;graph&nbsp;=&nbsp;_manager.FindEntityGraph(roots,&nbsp;spans,&nbsp;<span style="color: rgb43, 145, 175;">EntityState</span>.AllButDetached);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green;">/*</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;graph</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;=&nbsp;3</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;0&#093;:&nbsp;{SubjectForm:&nbsp;-102}&nbsp;-&nbsp;Added</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;1&#093;:&nbsp;{Form:&nbsp;1000004}&nbsp;-&nbsp;Unchanged</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;2&#093;:&nbsp;{Subject:&nbsp;1000001}&nbsp;-&nbsp;Unchanged</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;sandbox&nbsp;=&nbsp;<span style="color: blue;">new</span> <span style="color: rgb43, 145, 175;">MyEntityManager</span>();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sandbox.ImportEntities(graph,&nbsp;<span style="color: rgb43, 145, 175;">MergeStrategy</span>.OverwriteChanges);<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green;">/* </span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sandbox.FindEntities(EntityState.AllButDetached).OfType&lt;object&gt;().ToList()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;=&nbsp;3</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;0&#093;:&nbsp;{SubjectForm:&nbsp;-100}&nbsp;-&nbsp;Added</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;1&#093;:&nbsp;{Form:&nbsp;1000004}&nbsp;-&nbsp;Unchanged</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#091;2&#093;:&nbsp;{Subject:&nbsp;1000001}&nbsp;-&nbsp;Unchanged</span><br><span style="color: green;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><br> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">var</span>&nbsp;clone&nbsp;=&nbsp;sandbox.FindEntity(sf3.EntityAspect.EntityKey);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb43, 145, 175;">Assert</span>.IsNotNull(clone); //</font><font face="Courier New, Courier, mono" size="2"><span style="color: green;">SubjectForm got a new ID and can not be found</span></font><br></pre><br>]]>
   </description>
   <pubDate>Tue, 22 Mar 2011 03:12:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2574&amp;PID=10241#10241</guid>
  </item> 
 </channel>
</rss>