<?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 : Creating a Clone of an Object</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Creating a Clone of an Object</description>
  <pubDate>Tue, 28 Apr 2026 18:04:22 -700</pubDate>
  <lastBuildDate>Fri, 21 Aug 2009 12:36:45 -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=874</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>Creating a Clone of an Object : I recently wrote more about cloning...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=5219#5219</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=482" rel="nofollow">WardBell</a><br /><strong>Subject:</strong> 874<br /><strong>Posted:</strong> 21-Aug-2009 at 12:36pm<br /><br />I recently wrote more about cloning as of the 5.2.2 release of DevForce in another forum post: <a href="http://www.ideablade.com/forum/forum_posts.asp?TID=1437&amp;PID=5218#5218" target="_blank">http://www.ideablade.com/forum/forum_posts.asp?TID=1437&amp;PID=5218#5218</A>]]>
   </description>
   <pubDate>Fri, 21 Aug 2009 12:36:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=5219#5219</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : Somewhere between versions we...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=4151#4151</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> 874<br /><strong>Posted:</strong> 23-Mar-2009 at 12:10pm<br /><br />Somewhere between versions we went from a public virtual Clone() method to an explicit interface implementation.&nbsp; You must now cast your entity to an ICloneable in order to call Clone, and it's not overrideable.]]>
   </description>
   <pubDate>Mon, 23 Mar 2009 12:10:20 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=4151#4151</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : Alright I&amp;#039;m a bit confused...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=4148#4148</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=452" rel="nofollow">ken.nelson</a><br /><strong>Subject:</strong> 874<br /><strong>Posted:</strong> 23-Mar-2009 at 8:46am<br /><br />Alright I'm a bit confused on this, I'm attempting to follow this post.&nbsp; I'm using version 4.3.0 and the release notes of version 4.3.0 indicate:<DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td class="BBquote"></DIV><DIV><P align=left></P><FONT size=2><P>Entity.Clone now sets EntityState as detached and allows dynamic recreation of EntityKey. &#091;#839&#093; </P></FONT></DIV><DIV></td></tr></table></DIV><DIV>&nbsp;</DIV><DIV>Fantastic.&nbsp;&nbsp; But, I can't seem to find Clone() anywhere in the Entity class (or any class that I've derived from it).&nbsp; I've looked in the Object Browser and went to the definition on Entity, but neither lists a Clone() method at all, let alone one that is overridable.&nbsp; All I'm seeing is a CloneCore method that is not overridable.&nbsp; Even more confusing is that Entity derives from the ICloneable interface, which indicates that the Clone() method should indeed still exist.</DIV><DIV>&nbsp;</DIV><DIV>I feel like I'm missing a key step, but not sure what it is.&nbsp; My references include IdeaBlade.EntityModel.v4, IdeaBlade.Util.v4, and IdeaBlade.Verification.v4.&nbsp; A shot in the dark, but is there another library I need to be referencing to be able to 'see' the Clone() method?</DIV><DIV>&nbsp;</DIV><DIV>Thanks,</DIV><DIV>Ken</DIV>]]>
   </description>
   <pubDate>Mon, 23 Mar 2009 08:46:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=4148#4148</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : The problem has been fixed in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3432#3432</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> 874<br /><strong>Posted:</strong> 25-Sep-2008 at 9:04am<br /><br />The problem has been fixed in current bits and will be available in the October release.&nbsp; We don't have a firm date for this release yet.]]>
   </description>
   <pubDate>Thu, 25 Sep 2008 09:04:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3432#3432</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : Do you when this feature be in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3426#3426</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=377" rel="nofollow">pokaragat</a><br /><strong>Subject:</strong> 874<br /><strong>Posted:</strong> 23-Sep-2008 at 8:54am<br /><br />Do you when this feature be in the build and release date?]]>
   </description>
   <pubDate>Tue, 23 Sep 2008 08:54:11 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3426#3426</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : Unfortunately, in DevForce version...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3425#3425</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> 874<br /><strong>Posted:</strong> 22-Sep-2008 at 6:37pm<br /><br />Unfortunately, in DevForce version 4.2.0.1 the Clone capability appears to be broken.&nbsp; So, your best option right now might be to create a new entity and copy all properties one-by-one from the original entity.&nbsp; <DIV>&nbsp;</DIV><DIV>Clone should be fixed in the next release.</DIV>]]>
   </description>
   <pubDate>Mon, 22 Sep 2008 18:37:46 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3425#3425</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : I tried to override the Clone...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3419#3419</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=377" rel="nofollow">pokaragat</a><br /><strong>Subject:</strong> 874<br /><strong>Posted:</strong> 22-Sep-2008 at 10:38am<br /><br /><P>I tried to override the Clone method:</P><DIV><FONT color=#0000ff size=2>this</FONT><FONT size=2>.RemoveFromManager();</DIV><DIV><DIV></FONT><FONT color=#2b91af size=2>DATA_ENTRY</FONT><FONT size=2> dataEntry =(</FONT><FONT color=#2b91af size=2>DATA_ENTRY</FONT><FONT size=2>) </FONT><FONT color=#0000ff size=2>base</FONT><FONT size=2>.Clone();</FONT></DIV><DIV><FONT size=2>dataEntry.DATA_ENTRY_ID = 102;</FONT></DIV><DIV><FONT size=2>dataEntry.DATA_ENTRY_FROM_DATE = </FONT><FONT color=#2b91af size=2>DateTime</FONT><FONT size=2>.Now;</FONT></DIV><DIV><FONT size=2>manager.AddEntity(dataEntry);</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>It allowed me to modify the fields for the primary keys, however, the cloned object still bears the EntityKey of the original object. So when added to the manager an exception is thrown saying the object already existed.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Please help.</DIV></FONT></DIV>]]>
   </description>
   <pubDate>Mon, 22 Sep 2008 10:38:18 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3419#3419</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : Our way of doing auditing is on...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3410#3410</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=377" rel="nofollow">pokaragat</a><br /><strong>Subject:</strong> 874<br /><strong>Posted:</strong> 20-Sep-2008 at 5:47am<br /><br /><P>Our way of doing auditing is on the same table. The modified row will actually be marked as inactive and a new row is created as a result of the update. So, the easiest way is to clone the object and mark the original version as inactive. The cloned object will be the latest version. Version is part of the primary key, so it is part of the identity of the new version.</P><P>Hope this helps.</P><P>&nbsp;</P>]]>
   </description>
   <pubDate>Sat, 20 Sep 2008 05:47:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3410#3410</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : It looks like Clone() is no longer...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3407#3407</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> 874<br /><strong>Posted:</strong> 19-Sep-2008 at 4:18pm<br /><br />It looks like Clone() is no longer leaving the cloned entity in a Detached EntityState, but instead it's getting the EntityState of the original object (I'll need to check why this was done, since it seems like a bug).&nbsp; So, because of this things are a little confused when you go to modify the EntityKey of the cloned object.&nbsp; It should work if you call RemoveFromManager() on the original object before performing the clone.&nbsp; This will put both the original and cloned entities in a Detached state.<DIV>&nbsp;</DIV><DIV>I guess I should ask what your use case here is, just in case there are other ways of accomplishing what you need.</DIV>]]>
   </description>
   <pubDate>Fri, 19 Sep 2008 16:18:22 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3407#3407</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object :    I have the same need of...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3404#3404</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=377" rel="nofollow">pokaragat</a><br /><strong>Subject:</strong> 874<br /><strong>Posted:</strong> 19-Sep-2008 at 2:39pm<br /><br /><DIV></DIV><DIV><FONT size=2><P></FONT><FONT color=#0000ff size=2></P><DIV>I have the same need of modifying the data after it was cloned, modify the primary keys. So I did an override as below:</DIV><DIV>&nbsp;</DIV><DIV>public</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>override</FONT><FONT size=2> </FONT><FONT color=#2b91af size=2>Entity</FONT><FONT size=2> Clone()</FONT></DIV><DIV><FONT size=2>{</FONT></DIV><DIV><FONT color=#2b91af size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DATA_ENTRY</FONT><FONT size=2> dataEntry =(</FONT><FONT color=#2b91af size=2>DATA_ENTRY</FONT><FONT size=2>) </FONT><FONT color=#0000ff size=2>base</FONT><FONT size=2>.Clone();</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataEntry.DATA_ENTRY_ID = 100;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataEntry.DATA_ENTRY_FROM_DATE = </FONT><FONT color=#2b91af size=2>DateTime</FONT><FONT size=2>.UtcNow;</FONT></DIV><DIV><FONT color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return</FONT><FONT size=2> dataEntry;</FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>----</FONT></DIV><DIV><FONT size=2>These two lines modify the primary keys of the entity:</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><FONT size=2><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataEntry.DATA_ENTRY_ID = 100;</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataEntry.DATA_ENTRY_FROM_DATE = </FONT><FONT color=#2b91af size=2>DateTime</FONT><FONT size=2>.UtcNow;</FONT></DIV><DIV></FONT><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>The call threw an exception:</DIV></FONT></DIV><DIV>"The given key was not present in the dictionary."</DIV><DIV>&nbsp;</DIV><DIV>Is there a way to go around this one?</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Fri, 19 Sep 2008 14:39:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3404#3404</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : There&amp;#039;s an Entity.Clone method...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3187#3187</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> 874<br /><strong>Posted:</strong> 08-Jul-2008 at 12:09pm<br /><br />There's an Entity.Clone method which should do what you need.&nbsp; It will copy member values but leave the new entity in a detached state.&nbsp; This method is also overridable if you need to perform custom logic.]]>
   </description>
   <pubDate>Tue, 08 Jul 2008 12:09:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3187#3187</guid>
  </item> 
  <item>
   <title>Creating a Clone of an Object : In DEF, what would be the best...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3180#3180</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=275" rel="nofollow">danielp37</a><br /><strong>Subject:</strong> 874<br /><strong>Posted:</strong> 07-Jul-2008 at 11:41am<br /><br />In DEF, what would be the best way to create a Clone of an Object that would have all the same properties of the original object, but would be not be added to the EntityManager so it could be modified slightly, given a different primary key and then added to the EntityManager as a separate object.&nbsp; I notice that there is a MemberwiseClone method, but I'm not sure that is going to do what I want.<br><br>Thanks,<br><br>Dan<br>]]>
   </description>
   <pubDate>Mon, 07 Jul 2008 11:41:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=874&amp;PID=3180#3180</guid>
  </item> 
 </channel>
</rss>