<?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 : Deep copy an entity tree</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Deep copy an entity tree</description>
  <pubDate>Wed, 10 Jun 2026 17:29:34 -700</pubDate>
  <lastBuildDate>Tue, 31 Aug 2010 13:37:01 -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=2089</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>Deep copy an entity tree : Clone will be fixed for the release...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8296#8296</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 2089<br /><strong>Posted:</strong> 31-Aug-2010 at 1:37pm<br /><br />Clone will be fixed for the release this week.&nbsp; Sorry for the false start!<DIV></DIV>]]>
   </description>
   <pubDate>Tue, 31 Aug 2010 13:37:01 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8296#8296</guid>
  </item> 
  <item>
   <title>Deep copy an entity tree : My bad. I should have tested this...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8230#8230</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 2089<br /><strong>Posted:</strong> 26-Aug-2010 at 4:28pm<br /><br /><P>My bad.&nbsp; I should have tested this first.&nbsp; ICloneable.Clone&nbsp;does not have the correct implemenation.&nbsp; I have an architect looking at this.</P><DIV></DIV><span style="font-size:10px"><br /><br />Edited by ting - 26-Aug-2010 at 4:29pm</span>]]>
   </description>
   <pubDate>Thu, 26 Aug 2010 16:28:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8230#8230</guid>
  </item> 
  <item>
   <title>Deep copy an entity tree : Thanks Ting,  If I do as you...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8202#8202</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=891" rel="nofollow">bigme</a><br /><strong>Subject:</strong> 2089<br /><strong>Posted:</strong> 25-Aug-2010 at 9:20pm<br /><br />Thanks Ting,<br><br>&nbsp;If I do as you say above then I get a new order (without OrderDetails), but the original order has its PK changed to the same value as the newly added order !!<br><br>So it seemed that I should NOT explicitly add the cloned Order to the mgr.Orders collection, but just rely on the cloning of the Customer navigation property? When I do this I don't get a new Order, but it still changes the PK of the current order (the one being cloned)<br><br>I suspect this is related to the fact that I am working with a collection of customer.Orders and not mgr.Orders?? <br><br>Dave.]]>
   </description>
   <pubDate>Wed, 25 Aug 2010 21:20:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8202#8202</guid>
  </item> 
  <item>
   <title>Deep copy an entity tree : You can clone an entity by explicitly...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8201#8201</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 2089<br /><strong>Posted:</strong> 25-Aug-2010 at 7:43pm<br /><br />You can clone an entity by explicitly casting to IClonable and calling Clone().&nbsp; This will return you a detatched entity with all of the fields copied.&nbsp; You should now&nbsp;call EntityManager.GenerateID() to assign it a new primary key and add it to the EntityManager.&nbsp; Make sure to assign the primary key before adding it to the EntityManager.<DIV>&nbsp;</DIV><DIV>Here's an example:</DIV><DIV><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> newEmployee = (</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>) ((</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>ICloneable</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>)employee).Clone();</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>mgr.GenerateId(newEmployee, </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>PropertyMetadata</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.EmployeeID);</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>mgr.AddEntity(newEmployee);</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp;</DIV></FONT></FONT>]]>
   </description>
   <pubDate>Wed, 25 Aug 2010 19:43:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8201#8201</guid>
  </item> 
  <item>
   <title>Deep copy an entity tree : The Order and OrderDetails are,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8194#8194</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=891" rel="nofollow">bigme</a><br /><strong>Subject:</strong> 2089<br /><strong>Posted:</strong> 25-Aug-2010 at 3:29pm<br /><br />The Order and OrderDetails are, of course, standard IdeaBlade-generated objects and collections, a la Northwind.<br><br>Dave.<br>]]>
   </description>
   <pubDate>Wed, 25 Aug 2010 15:29:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8194#8194</guid>
  </item> 
  <item>
   <title>Deep copy an entity tree : I have an existing Order and a...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8167#8167</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=891" rel="nofollow">bigme</a><br /><strong>Subject:</strong> 2089<br /><strong>Posted:</strong> 24-Aug-2010 at 4:44pm<br /><br />I have an existing Order and a collection of OrderDetails that I need to duplicate as the basis for a new order. At the moment I simply create new entities and copy the properties I want. Is there a less brittle, more DevForce-oriented way to do this?<br><br>Dave.<br><br>]]>
   </description>
   <pubDate>Tue, 24 Aug 2010 16:44:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;PID=8167#8167</guid>
  </item> 
 </channel>
</rss>