<?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 : Cascading Deletes</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Cascading Deletes</description>
  <pubDate>Sun, 12 Apr 2026 23:35:08 -700</pubDate>
  <lastBuildDate>Sat, 01 Sep 2007 21:41:07 -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=398</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>Cascading Deletes : Found in another post the ShouldRemoveDeletedEntities...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=398&amp;PID=1041#1041</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=101" rel="nofollow">JulianBenjamin</a><br /><strong>Subject:</strong> 398<br /><strong>Posted:</strong> 01-Sep-2007 at 9:41pm<br /><br />Found in another post the ShouldRemoveDeletedEntities option on the EntityList.&nbsp; So it's fine.]]>
   </description>
   <pubDate>Sat, 01 Sep 2007 21:41:07 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=398&amp;PID=1041#1041</guid>
  </item> 
  <item>
   <title>Cascading Deletes : Actually, I had to change the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=398&amp;PID=1040#1040</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=101" rel="nofollow">JulianBenjamin</a><br /><strong>Subject:</strong> 398<br /><strong>Posted:</strong> 01-Sep-2007 at 9:33pm<br /><br /><P>Actually, I had to change the code, as the enumerated list changed each time I called "delete".</P><P>But, how do I get it removed from the database?&nbsp; After I add it to the entitylist, it gets removed when I call the delete method.&nbsp; So the call to SaveChanges gets an empty EntityList.&nbsp; Is there something I'm missing?</P>]]>
   </description>
   <pubDate>Sat, 01 Sep 2007 21:33:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=398&amp;PID=1040#1040</guid>
  </item> 
  <item>
   <title>Cascading Deletes : *** This is fixed. ***  When...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=398&amp;PID=1039#1039</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=101" rel="nofollow">JulianBenjamin</a><br /><strong>Subject:</strong> 398<br /><strong>Posted:</strong> 01-Sep-2007 at 6:03pm<br /><br /><DIV>***&nbsp; This is fixed. ***</DIV><DIV>&nbsp;</DIV><DIV>When deleting related objects (such as addresses, contacts for an agency), what's the best way of doing this?&nbsp; There's no direct relation (on the database) between the parent and child, as the addresses and contacts could contain records for other entities such as clients, organizations, etc.&nbsp; They are tied to each other by an EntityId column of type Guid, so it's unique, and DevForce has this mapping as well to load the related records.</DIV><DIV>What I'm doing in the Delete method is creating an EntityList&lt;Entity&gt;, recursing through the contacts and addresses objects of the item being deleted, adding them to the EntityList and calling the delete function on them.&nbsp; Then I add the Agency object to the list, call it's Delete function, and call the Save method on the PersistenceManager passing the EntityList to it.&nbsp; Is this the best (or only)&nbsp;way?&nbsp; I've included the Delete function below.</DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td><pre class="BBcode"></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static void Delete(Agency agency)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityList&lt;Entity&gt; changedEntities = new EntityList&lt;Entity&gt;();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(Contact contact in agency.Contacts)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; changedEntities.Add(contact);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contact.Delete();<BR>&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(Note note in agency.Notes)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; changedEntities.Add(note);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; note.Delete();<BR>&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(AgencyClients agencyclient in agency.Clients)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; changedEntities.Add(agencyclient);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; agencyclient.Delete();<BR>&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(Address address in agency.Addresses)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; changedEntities.Add(address);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; address.Delete();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; changedEntities.Add(agency);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; agency.Delete();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mPersManager.SaveChanges(changedEntities);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR></DIV><DIV></pre></td></tr></table></DIV><DIV>&nbsp;</DIV><DIV>Thanks, </DIV><DIV>&nbsp;</DIV><DIV>Julian</DIV><span style="font-size:10px"><br /><br />Edited by JulianBenjamin - 01-Sep-2007 at 9:41pm</span>]]>
   </description>
   <pubDate>Sat, 01 Sep 2007 18:03:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=398&amp;PID=1039#1039</guid>
  </item> 
 </channel>
</rss>