<?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 Clone</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Deep Clone</description>
  <pubDate>Thu, 23 May 2013 03:52:48 -700</pubDate>
  <lastBuildDate>Sun, 17 Jul 2011 03:14:41 -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=2171</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 Clone : the interface is simplepublic...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=11249#11249</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 17-Jul-2011 at 3:14am<br /><br />the interface is simple<div><br><div><div>public interface&nbsp;<span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">IMyCloningMethods</span></div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; void GetEntityGraphAsync(Action&lt;IList&lt;Object&gt;&gt; callback);</div><div>&nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; }</div></div><div><br></div></div><div>What you do is for each object you use findentitygraph to return a list of related objects to the depth you require.</div><div><br></div><div><a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/save-dependency-graph" target="_blank">http://drc.ideablade.com/xwiki/bin/view/Documentation/save-dependency-graph</a></div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Sun, 17 Jul 2011 03:14:41 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=11249#11249</guid>
  </item> 
  <item>
   <title>Deep Clone : I realize this is an old thread,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=11245#11245</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1207" rel="nofollow">stevef</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 15-Jul-2011 at 12:13pm<br /><br />I realize this is an old thread, last msg sent being from a year ago.&nbsp; But I sure could use this functionality.<DIV>I'm surprised this is not already provided by DevForce.&nbsp; I realize the complexity of deep-cloning the graph.&nbsp; But as Ward suggested, this indeed can be handled via metadata (ala the buddy classes that can be created to implement verification), to indicate what is clonable and what is not.</DIV><DIV>Alternately, why not provide a deep-clone method, with a depth parameter?</DIV><DIV>&nbsp;</DIV><DIV>In lieu of using something from IB, I would like to use hueha's suggested implementation, but the code posted here is missing definition of IMyCloningMethods, and I'm at a loss when it comes to inferring its implementation.</DIV><DIV>Any chance of posting it, hueha?</DIV><DIV>I'd be much obliged.</DIV><DIV>&nbsp;</DIV><DIV>Thanks,<BR></DIV>]]>
   </description>
   <pubDate>Fri, 15 Jul 2011 12:13:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=11245#11245</guid>
  </item> 
  <item>
   <title>Deep Clone : ok rewritten the two routines...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9047#9047</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 09-Nov-2010 at 4:20am<br /><br />ok rewritten the two routines that use reflection to use the entitymetadata. &nbsp;It's whole lot simpler and easier to work with<div><br></div><div><div>private static void FixForeignKeys(Entity clone, Dictionary&lt;EntityKey, Entity&gt; clonedItems)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EntityMetadata cloneEntityMetadata = EntityMetadataStore.Instance.GetEntityMetadata(clone.GetType());</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var prop in cloneEntityMetadata.ScalarNavigationProperties)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EntityKey key =((Entity) prop.GetValue(clone)).EntityAspect.EntityKey ;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (clonedItems.ContainsKey(key))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var newRelatedItem = clonedItems&#091;key&#093;;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prop.SetValue(clone, newRelatedItem);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;private static void RelinkRelations(Entity objectToClone, Entity clone, Dictionary&lt;EntityKey, Entity&gt; clonedItems)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EntityMetadata cloneEntityMetadata = EntityMetadataStore.Instance.GetEntityMetadata(clone.GetType());</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var listNavigationProperty in cloneEntityMetadata.ListNavigationProperties)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IList listToClone = (IList)listNavigationProperty.GetValue(objectToClone);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IList listOfClone = (IList)listNavigationProperty.GetValue(clone);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//Need an umboundList because the list could be updated by the addition of new clones e.g. in many to many relationships</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;List&lt;Entity&gt; unboundListToClone = new List&lt;Entity&gt;();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var listItem in listToClone)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (listItem is Entity)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unboundListToClone.Add((Entity)listItem);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var listItem in unboundListToClone)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Entity relatedObject;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (clonedItems.ContainsKey(listItem.EntityAspect.EntityKey))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;relatedObject = clonedItems&#091;listItem.EntityAspect.EntityKey&#093;;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;relatedObject = listItem;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;listOfClone.Add(relatedObject);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div></div><div><br></div>]]>
   </description>
   <pubDate>Tue, 09 Nov 2010 04:20:58 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9047#9047</guid>
  </item> 
  <item>
   <title>Deep Clone : public static void DeepClone(Entity...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9045#9045</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 09-Nov-2010 at 2:16am<br /><br /><div>public static void DeepClone(Entity objectToClone, JTS2Entities mgr, Action&lt;Entity&gt; callBack)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Dictionary&lt;EntityKey, Entity&gt; clonedItems = new Dictionary&lt;EntityKey, Entity&gt;();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DeepClone( objectToClone, mgr, clonedItems, callBack);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;private static void DeepClone(Entity objectToClone, JTS2Entities mgr, Dictionary&lt;EntityKey, Entity&gt; clonedItems, Action&lt;Entity&gt; callBack)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;((IMyCloningMethods) objectToClone).GetEntityGraphAsync((list) =&gt;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//set up clones</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (Entity relatedItem in list)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Entity relatedClone=(Entity) ((ICloneable) relatedItem).Clone();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MakeUnique((IMyCloningMethods) relatedClone);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mgr.AddEntity(relatedClone);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;clonedItems.Add(relatedItem.EntityAspect.EntityKey, relatedClone);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//fix up IDs</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (Entity relatedItem in list)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FixForeignKeys(clonedItems&#091;relatedItem.EntityAspect.EntityKey&#093;, clonedItems);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (Entity relatedItem in list)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RelinkRelations(relatedItem, clonedItems&#091;relatedItem.EntityAspect.EntityKey&#093;, clonedItems);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;callBack(clonedItems&#091;objectToClone.EntityAspect.EntityKey&#093;);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><div>private static void FixForeignKeys(Entity clone, Dictionary&lt;EntityKey, Entity&gt; clonedItems)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var props = clone.GetType().GetProperties();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var prop in props)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var attr = prop.GetCustomAttributes(typeof(RelationPropertyAttribute), true);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (attr.Length &gt; 0)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (((RelationPropertyAttribute)attr&#091;0&#093;).QueryDirection == QueryDirection.ToRole2)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!IsSubclassOfRawGeneric(typeof(RelatedEntityList&lt;&gt;), prop.PropertyType))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EntityKey key = ((Entity)prop.GetGetMethod().Invoke(clone, null)).EntityAspect.EntityKey;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (clonedItems.ContainsKey(key))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var newRelatedItem = clonedItems&#091;key&#093;;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prop.GetSetMethod().Invoke(clone, new object&#091;&#093; { newRelatedItem });</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;private static void RelinkRelations(Entity objectToClone, Entity clone, Dictionary&lt;EntityKey, Entity&gt; clonedItems)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var props = objectToClone.GetType().GetProperties();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var prop in props)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (IsSubclassOfRawGeneric(typeof(RelatedEntityList&lt;&gt;), prop.PropertyType))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IList listToClone = (IList)prop.GetGetMethod().Invoke(objectToClone, null);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IList listOfClone = (IList)prop.GetGetMethod().Invoke(clone, null);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;listOfClone.Clear();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (listToClone != null)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//Need an umboundList because the list could be updated by the addition of new clones e.g. in many to many relationships</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;List&lt;Entity&gt; unboundListToClone = new List&lt;Entity&gt;();</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var listItem in listToClone)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (listItem is Entity)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;unboundListToClone.Add((Entity)listItem);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var listItem in unboundListToClone)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Entity relatedObject;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (clonedItems.ContainsKey(listItem.EntityAspect.EntityKey))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;relatedObject = clonedItems&#091;listItem.EntityAspect.EntityKey&#093;;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;relatedObject = listItem;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;listOfClone.Add(relatedObject);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;static bool IsSubclassOfRawGeneric(Type generic, Type toCheck)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while (toCheck != typeof(object))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var cur = toCheck.IsGenericType ? toCheck.GetGenericTypeDefinition() : toCheck;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (generic == cur)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return true;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;toCheck = toCheck.BaseType;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return false;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;static private void MakeUnique(IMyCloningMethods&nbsp;entity)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foreach (var propName in entity.FieldsWithUniqueConstraint) //this is a list of field names (string) that I maintain manually in code</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var prop = entity.GetType().GetProperty(propName);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//make name unique then set it back to the property</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;object&#091;&#093; parameters = {prop.GetGetMethod().Invoke(entity, null) + " copied on " + DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss")};</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prop.GetSetMethod().Invoke(entity, parameters);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div></div><div><br></div>]]>
   </description>
   <pubDate>Tue, 09 Nov 2010 02:16:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9045#9045</guid>
  </item> 
  <item>
   <title>Deep Clone : Yeah I eventually came to the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9044#9044</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 09-Nov-2010 at 2:12am<br /><br /><div>Yeah I eventually came to the same conclusion. &nbsp;To get the list of objects to clone I now use have a method on all my entities that uses EntityAspect.EntityManager.FindEntityGraph to return the objects I want to clone. &nbsp;Then I clone all the items and keep a mapping table to map clones to the original object. &nbsp;I need to do this in order to remap all the related objects to the corresponding clones. &nbsp;I used reflection to get to your property attributes. &nbsp;I'll post my code in the next post. &nbsp;Do you think I should rewrite using the GetEntityMetadata?</div>]]>
   </description>
   <pubDate>Tue, 09 Nov 2010 02:12:15 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9044#9044</guid>
  </item> 
  <item>
   <title>Deep Clone : You may not need reflection.   DevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9042#9042</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> 2171<br /><strong>Posted:</strong> 08-Nov-2010 at 8:29pm<br /><br />You may not need reflection. <DIV>&nbsp;</DIV><DIV>DevForce maintains a MetadataStore with a wealth of information about entities and their relationships. You can get the metadata for an entity type via<FONT size=2></DIV><P>&nbsp;&nbsp; IdeaBlade.EntityModel.<strong>EntityMetadataStore.Instance.GetEntityMetadata</strong>(someType)</P><DIV>The method takes a type (rather than a generic type parameter) as you can see so it should be easy for you to assemble the pieces you need for any arbitrary type to get a complete vision of the graph that you will need before making any async calls. </DIV><DIV>&nbsp;</DIV><DIV>You can use Coroutine.Parallel to construct a series of parallel async calls to retrieve the related entities and their related entities ... up to the depth of the clone you need.</DIV><DIV>&nbsp;</DIV><DIV>You probably don't want clone every related entity. For example, if a Customer has a navigation to a CustomerCode entity, you probably don't clone the code. There is nothing in the graph structure per se that tells you what to clone and what not to clone. Nothing in the graph structure tells you how deep to clone ... how far to go along the navigation paths. I don't know how you can make any of these decisions a priori; you have to bring some business knowledge to the table ... perhaps in the form of your own metadata (which would also know which values must be unique and how to make them unique ... information not available to us from EF).</DIV><DIV>&nbsp;</DIV><DIV>These are some of the reasons that we don't give you an automated deep clone facility.</DIV><DIV>&nbsp;</DIV><DIV>I can imagine coupling your own metadata to some generalized cloning machinery. When you figure this out, you might choose to perform all of your cloning in a separate Entity Manager to isolate that activity from everything in your main manager.</DIV><DIV>&nbsp;</DIV><DIV>Obviously this is more involved than any of us would like. It's not a scenario we've run into often.</DIV></FONT>]]>
   </description>
   <pubDate>Mon, 08 Nov 2010 20:29:02 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=9042#9042</guid>
  </item> 
  <item>
   <title>Deep Clone : 1) I was afraid you were gonna...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8805#8805</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 16-Oct-2010 at 6:04am<br /><br />1) I was afraid you were gonna say that. &nbsp;I guess I'll have to keep a list myself of any unique columns belonging to that object<div>2) The problem is I'm trying to do it generically using reflection so there could be multiple steps needing to be resolved. &nbsp;I suppose I could jump into the clone method recursively and asynchronously but the concept is starting to cause a stack overflow in my mind :D. &nbsp;I'll give it a go</div>]]>
   </description>
   <pubDate>Sat, 16 Oct 2010 06:04:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8805#8805</guid>
  </item> 
  <item>
   <title>Deep Clone : Hi,   1) Unfortunately you will...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8767#8767</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> 2171<br /><strong>Posted:</strong> 12-Oct-2010 at 9:48am<br /><br />Hi, <DIV>&nbsp;</DIV><DIV>1) Unfortunately you will not be able to know if a field is a unique index (if not part of the PK)</DIV><DIV>&nbsp;</DIV><DIV>2) since it's async, you must wait until it's resolved:</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><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></FONT></FONT></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><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>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><FONT color=#000000>&nbsp;orders = aCustomer.Orders;</FONT></FONT></FONT></FONT></DIV><DIV><FONT size=2><FONT face=C&#111;nsolas>&nbsp; <FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff>foreach</FONT></FONT></FONT> (<FONT color=#2b91af><FONT color=#2b91af><FONT color=#2b91af>Order</FONT></FONT></FONT> order <FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff>in</FONT></FONT></FONT></FONT><FONT face=C&#111;nsolas> orders) {</FONT></FONT></DIV><DIV><FONT size=2><FONT face=C&#111;nsolas>&nbsp;&nbsp;&nbsp; </FONT><FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff face=C&#111;nsolas>if</FONT></FONT></FONT><FONT face=C&#111;nsolas> (order.EntityAspect.IsPendingEntity) {</FONT></FONT></DIV><DIV><FONT size=2><FONT face=C&#111;nsolas>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; order.EntityAspect.PendingEntityResolved += <FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff>new</FONT></FONT></FONT> <FONT color=#2b91af><FONT color=#2b91af><FONT color=#2b91af>EventHandler</FONT></FONT></FONT>&lt;<FONT color=#2b91af><FONT color=#2b91af><FONT color=#2b91af>PendingEntityResolvedEventArgs&gt;</FONT></FONT></FONT></FONT><FONT face=C&#111;nsolas>(PendingEntityResolved);</FONT></FONT></DIV><DIV><FONT size=2><FONT face=C&#111;nsolas>&nbsp;&nbsp;&nbsp; </FONT><FONT face=C&#111;nsolas>}</FONT></FONT></DIV><DIV><DIV><FONT size=2 face=C&#111;nsolas>&nbsp; }</FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas>&nbsp; .</FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas>&nbsp; .</FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas>&nbsp; .</FONT></DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas></FONT></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; void</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> PendingEntityResolved(</FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>object</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> sender, </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>PendingEntityResolvedEventArgs</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> e) {</DIV><DIV><DIV></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>&nbsp;&nbsp;&nbsp; <FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas>//&nbsp;some code</FONT></FONT></FONT></FONT></FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp; }</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp;</DIV></FONT></FONT></DIV></DIV>]]>
   </description>
   <pubDate>Tue, 12 Oct 2010 09:48:27 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8767#8767</guid>
  </item> 
  <item>
   <title>Deep Clone : sorry I should have been more...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8735#8735</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 06-Oct-2010 at 3:00pm<br /><br />sorry I should have been more specific<br>1) The unique index is not part of the primary key.&nbsp; <br>2) I can tell they are pending but how do I force the entire entity graph to load.&nbsp; I can't use a query to put them in cache because it is a generic function and all I know is that it is an entity object which might or might not have a relatedentitylist<br><br>]]>
   </description>
   <pubDate>Wed, 06 Oct 2010 15:00:12 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8735#8735</guid>
  </item> 
  <item>
   <title>Deep Clone : hueha,  You can use   anEn...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8730#8730</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> 2171<br /><strong>Posted:</strong> 06-Oct-2010 at 10:40am<br /><br />hueha,<DIV>&nbsp;</DIV><DIV>You can use </DIV><DIV>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas>anEntity.EntityAspect.EntityMetadata.KeyProperties; </FONT></DIV><DIV>&nbsp;</DIV><DIV>to find out the entity key.</DIV><DIV>&nbsp;</DIV><DIV>You can also find if an entity is a pending entity with</DIV><DIV>&nbsp;</DIV><DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>anEntity.EntityAspect.IsPendingEntity;</DIV></FONT></FONT></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 06 Oct 2010 10:40:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8730#8730</guid>
  </item> 
  <item>
   <title>Deep Clone : 2) Another issue is how do I ensure...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8727#8727</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 06-Oct-2010 at 7:31am<br /><br />2) Another issue is how do I ensure none of the relatedentitylists are pending?]]>
   </description>
   <pubDate>Wed, 06 Oct 2010 07:31:16 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8727#8727</guid>
  </item> 
  <item>
   <title>Deep Clone : I&amp;#039;ve implemented what I outlined...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8724#8724</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 06-Oct-2010 at 7:04am<br /><br />I've implemented what I outlined above and it works more or less (I'll post code when I'm done) but I have the following issue<div><br></div><div>1) I have a unique index on a field (companyName) and when I clone the entity and save it I get a violation of unique constraint from the database. &nbsp;Is there a way of knowing what unique indices/constraints are in a model? &nbsp;If so I could append a string to ensure it is unique before saving the clone.</div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Wed, 06 Oct 2010 07:04:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8724#8724</guid>
  </item> 
  <item>
   <title>Deep Clone : I&amp;#039;ll try and write a generic...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8606#8606</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 23-Sep-2010 at 5:57am<br /><br />I'll try and write a generic deep clone function that uses reflection. &nbsp;Right now I'm thinking<div><br></div><div>1) Create clone</div><div>2) Reflect off properties and find any relatedentitylists</div><div>3) For each item in each RelatedEntityList</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;recursively call deep clone with item</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;set the property that is the same name as this class name to the clone</div><div><br></div><div><br></div><div>there are a couple of issues I can think of</div><div>1) I have a many to many relationship which could cause the recursion to loop infinitely. &nbsp;Maybe I could keep a track of original entity objects I have already cloned.</div><div>2) I'm assuming that any relationships are cleared from the clone. &nbsp;</div><div><br></div><div>For example&nbsp;lets say I have&nbsp;</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>a company table with a companyid</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;a location table with locationid, foreign key companyid</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;a contact table with contactid, foreign keys companyid, locationid</div><div><br></div><div>If I clone a contact and I set the locationid to the cloned location then the companyid should also point to the cloned company not the original one</div>]]>
   </description>
   <pubDate>Thu, 23 Sep 2010 05:57:16 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8606#8606</guid>
  </item> 
  <item>
   <title>Deep Clone : In order to do a deep clone, you...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8599#8599</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> 2171<br /><strong>Posted:</strong> 22-Sep-2010 at 11:54am<br /><br />In order to do a deep clone, you will need to implement it.<DIV>i.e. cloning an employee and his orders:</DIV><DIV><FONT color=#2b91af size=2 face=C&#111;nsolas></FONT>&nbsp;</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>&nbsp; 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>)anEmployee).Clone();</DIV><DIV><DIV>&nbsp; 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);</DIV><DIV>&nbsp; mgr.AddEntity(newEmployee);</DIV><DIV></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>&nbsp; IList</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</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>Order</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt; orders = anEmployee.Orders.ToList();</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; foreach</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>Order</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> ord </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>in</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> orders) {</DIV><DIV></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>&nbsp; &nbsp; Order</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> newOrder = (</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>Order</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>)ord).Clone();</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp; &nbsp; mgr.GenerateId(newOrder, </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>Order</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>.OrderID);</DIV><DIV>&nbsp; &nbsp; newOrder.Employee = newEmployee;</DIV><DIV>&nbsp; &nbsp; mgr.AddEntity(newOrder);</DIV><DIV>&nbsp; }</DIV></FONT></FONT></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 22 Sep 2010 11:54:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8599#8599</guid>
  </item> 
  <item>
   <title>Deep Clone :   Originally posted by davidklitzkeThe...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8592#8592</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 22-Sep-2010 at 6:51am<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by davidklitzke</strong></em><br /><br />The defect has been fixed.&nbsp; The 6.0.5 Release Notes say:<br><br>•&nbsp;&nbsp;&nbsp; The ICloneable.Clone() implementation on Entity previously caused the cloned entity to share its fields with the original entity. Fixed. &#091;B1545&#093;<br><br><br></td></tr></table><div>That's good news. &nbsp;So any ideas on doing a deep clone?</div>]]>
   </description>
   <pubDate>Wed, 22 Sep 2010 06:51:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8592#8592</guid>
  </item> 
  <item>
   <title>Deep Clone : The defect has been fixed. The...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8569#8569</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=23" rel="nofollow">davidklitzke</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 20-Sep-2010 at 9:17am<br /><br />The defect has been fixed.&nbsp; The 6.0.5 Release Notes say:<br><br>•&nbsp;&nbsp;&nbsp; The ICloneable.Clone() implementation on Entity previously caused the cloned entity to share its fields with the original entity. Fixed. &#091;B1545&#093;<br><br><br>]]>
   </description>
   <pubDate>Mon, 20 Sep 2010 09:17:16 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8569#8569</guid>
  </item> 
  <item>
   <title>Deep Clone : I have an entity and I want to...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8565#8565</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=870" rel="nofollow">hueha</a><br /><strong>Subject:</strong> 2171<br /><strong>Posted:</strong> 20-Sep-2010 at 6:09am<br /><br />I have an entity and I want to clone it as well as the related objects inside it but the clone should be detached without any keys. &nbsp;Someone posted the same question earlier this year&nbsp;<a href="http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;title=deep-copy-an-entity-tree" target="_blank">http://www.ideablade.com/forum/forum_posts.asp?TID=2089&amp;title=deep-copy-an-entity-tree</a>. &nbsp;Has the clone bug been fixed? &nbsp;They never did answer how to do a deep clone though. &nbsp;]]>
   </description>
   <pubDate>Mon, 20 Sep 2010 06:09:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2171&amp;PID=8565#8565</guid>
  </item> 
 </channel>
</rss>