<?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 : TechTip: Cascading Deletes</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : TechTip: Cascading Deletes</description>
  <pubDate>Tue, 14 Apr 2026 14:20:48 -700</pubDate>
  <lastBuildDate>Mon, 09 Jul 2007 12:12:24 -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=115</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>TechTip: Cascading Deletes :    Level 200 DevForce Express  View...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=115&amp;PID=253#253</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 115<br /><strong>Posted:</strong> 09-Jul-2007 at 12:12pm<br /><br /><TABLE cellSpacing=0 cellPadding=7 width="100%"><T><TR vAlign=top =#ffffff><TD width=454 height=18><a href="http://rs6.net/tn.jsp?t=pa4sz5bab.0.lirg6ubab.zufnlmbab.2355&amp;ts=S0241&amp;p=http%3A%2F%2Fwww.ideablade.com%2Ftech_tips_definiti&#111;ns.htm" target="_blank"><FONT title=http://rs6.net/tn.jsp?t=pa4sz5bab.0.lirg6ubab.zufnlmbab.2355&amp;ts=S0241&amp;p=http%3A%2F%2Fwww.ideablade.com%2Ftech_tips_definiti&#111;ns.htm face=Arial,Helvetica,sans-serif size=1>Level 200 <BR title=http://rs6.net/tn.jsp?t=pa4sz5bab.0.lirg6ubab.zufnlmbab.2355&amp;ts=S0241&amp;p=http%3A%2F%2Fwww.ideablade.com%2Ftech_tips_definiti&#111;ns.htm>DevForce Express</FONT></A></TD><TD width=158><DIV align=center><a href="http://rs6.net/tn.jsp?t=pa4sz5bab.0.nblx5vbab.zufnlmbab.2355&amp;ts=S0241&amp;p=http%3A%2F%2Fwww.ideablade.com%2Ftechtips_summary.html" target="_blank"><FONT title=http://rs6.net/tn.jsp?t=pa4sz5bab.0.nblx5vbab.zufnlmbab.2355&amp;ts=S0241&amp;p=http%3A%2F%2Fwww.ideablade.com%2Ftechtips_summary. face=Arial,Helvetica,sans-serif size=1>View Archived Tech Tips</FONT></A></DIV></TD></TR><TR vAlign=top =#ffffff><TD colSpan=2 height=18><TABLE cellSpacing=0 cellPadding=0 width="100%"><T><TR><TD width="8%"><img src="http://www.ideablade.com/images/lightbulb.jpg" height="33" width="33" border="0" /></TD><TD width="92%"><strong><FONT face=Arial,Helvetica,sans-serif size=2>Cascading Deletes</FONT></strong></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK4 hideFocus =0 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=2 width="100%"><T><TR><TD colSpan=3><P><FONT face=Arial,Helvetica,sans-serif size=2>Suppose we have a certain type of entity with related children. When we delete an instance of that entity, we want all of its children to be deleted as well. What's the best approach to implementing this capability in DevForce?<BR>When performing operations on the graph of an object, we need to keep in mind the potential difference between how that object graph appears in the PersistenceManager's local cache, and how it may appear in the data source. <BR>Suppose our object graph is for an Order object, and that the related objects we want to delete consist solely and entirely of the related OrderDetail objects. Assume, for a moment, the following:</FONT></P><UL><LI><FONT face=Arial,Helvetica,sans-serif size=2>We will access the OrderDetails of the Order to be deleted through the Order object's OrderDetails relation property; and </FONT><LI><FONT face=Arial,Helvetica,sans-serif size=2>We did not prefetch any OrderDetails </FONT></LI></UL><P><FONT face=Arial,Helvetica,sans-serif size=2>In that case, the OrderDetails in the cache for Order A will be those that existed at the time we first referenced that OrderDetails property in our code. If we have not referenced it prior to attempting the delete on Order A, it will be referenced for the first time in whatever method we provide to do the deletion. But either way, additional time will pass between the moment when we delete the Order and its OrderDetails and the moment when we commit those deletions to the datasource using a SaveChanges(). Unless we have some locking scheme in place to prevent other users from adding OrderDetails to Order A, the possibility exists that they will do so, and that we will still end up with orphaned OrderDetail records in the database.</FONT></P><P><FONT face=Arial,Helvetica,sans-serif size=2>If we don't want that to happen, then we have two choices:</FONT></P></TD></TR><TR><TD vAlign=line width="2%"><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>1.</FONT></DIV></TD><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Implement a locking scheme;</FONT></TD></TR><TR><TD vAlign=line><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>2.</FONT></DIV></TD><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Implement a trigger on the database that deletes the OrderDetail records when their Order record is deleted.</FONT></TD></TR><TR><TD vAlign=line><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>3.</FONT></DIV></TD><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Set the value of the Tag property for one of the RadioButtons to one of the possible values of the targetted business object property. Do the same for the remaining RadioButtons, until each possible value that the business object property can take on is represented by exactly one RadioButton.</FONT></TD></TR><TR><TD colSpan=3><P><FONT face=Arial,Helvetica,sans-serif size=2>All right, suppose we've done one of the preceding, or that we're willing to live with an occasional orphaned record in the database.<FONT color=#ff0000>*</FONT> </FONT></P><DIV>How can we implement the deletion of the OrderDetails?<BR><BR>There are three basic options (short of writing ad hoc code everywhere we want the operation to occur):<BR></DIV></TD></TR><TR vAlign=top><TD><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>1.</FONT></DIV></TD><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Override the Delete() method in the Order class</FONT></TD></TR><TR vAlign=top><TD><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>2.</FONT></DIV></TD><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Provide a separate method - let's call in DeleteGraph() - in the Order class to do the job, leaving the Delete() method alone; or</FONT></TD></TR><TR vAlign=top><TD><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>3.</FONT></DIV></TD><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Provide some other object to watch the PersistenceManager for Order deletions and step in to delete the related OrderDetails whenever such a deletion is requested. <DIV>&nbsp;</DIV></FONT></TD></TR><TR><TD colSpan=3><FONT size=2><FONT face=Arial,Helvetica,sans-serif><strong>Overriding the Delete() Method</strong><BR><BR>This option is the one that comes to mind first for many developers. However, prior to version 3.5.0 of DevForce, it was a pseudo-option, because the Delete() method in a DevForce business class was inherited from System.Data.DataRow, where it is marked as sealed (non-overrideable). But, beginning with version 3.5.0, the Entity class contains a Delete() method which shadows System.Data.DataRow, is marked as virtual, and can thus be overridden. <BR></FONT></FONT></TD></TR><TR><TD><FONT face=Arial,Helvetica,sans-serif size=2>&nbsp;</FONT></TD><TD width="3%"><FONT face=Arial,Helvetica,sans-serif size=2>&nbsp; </FONT></TD><TD width="95%"><FONT size=2><FONT face=Arial,Helvetica,sans-serif><FONT color=#ff0000>*</FONT> the incidence of which we could minimize by always doing a DataSourceOnly retrieval of the OrderDetail records just before marking them for deletion; and always calling SaveChanges() immediately after so marking them.</FONT></FONT></TD></TR><TR><TD colSpan=3><FONT face=Arial,Helvetica,sans-serif size=2>Here's a Delete() override that addresses the use case we proposed above for deletion of an Order and its related OrderDetails:</FONT></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK8 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=3 width="100%"><T><TR><TD width="3%">&nbsp;</TD><TD width="97%"><P><strong><FONT face=Arial,Helvetica,sans-serif size=2>C#:</FONT></strong></P><FONT face="Courier New,Courier,Monospace" color=#0000ff size=2>public override void</FONT><FONT face="Courier New,Courier,Monospace" color=#000000 size=2> Delete() {<BR>&nbsp;&nbsp;EntityList&lt;OrderDetail&gt; orderDetails =<BR>&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#0000ff>new</FONT> EntityList&lt;OrderDetail&gt;(<FONT color=#0000ff>this</FONT>.OrderDetails);<BR>&nbsp;&nbsp;<FONT color=#0000ff>int</FONT> orderDetailsCount = orderDetails.Count;<BR>&nbsp;&nbsp;<FONT color=#0000ff>for</FONT> (<FONT color=#0000ff>int</FONT> counter = 0; counter &lt; orderDetailsCount; counter++) {<BR>&nbsp;&nbsp;&nbsp;orderDetails&#091;0&#093;.Delete();<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;<FONT color=#0000ff>base</FONT>.Delete();<BR>}</FONT><FONT face="Courier New, Courier, mono" color=#0000ff><BR><BR></FONT><P><BR><FONT face=Arial,Helvetica,sans-serif><FONT size=2><strong>VB.NET:</strong> </FONT></FONT></P><FONT color=#0000ff><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Public</SPAN></FONT></FONT><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Overrides</SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Sub</SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-bidi-font-size: 10.0pt"> Delete()<BR></SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">&nbsp;&nbsp;Dim</SPAN><SPAN style="mso-bidi-font-size: 10.0pt"> orderDetails </SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">As</SPAN><SPAN style="mso-bidi-font-size: 10.0pt"> EntityList(</SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Of</SPAN><SPAN style="mso-bidi-font-size: 10.0pt"> OrderDetail) = </SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">New</SPAN><SPAN style="mso-bidi-font-size: 10.0pt"> EntityList(</SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Of</SPAN></FONT></FONT><SPAN style="mso-bidi-font-size: 10.0pt"><BR><FONT face="Courier New,Courier,Monospace" size=2>OrderDetail)(</FONT></SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt"><FONT face="Courier New,Courier,Monospace" size=2>Me</FONT></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-bidi-font-size: 10.0pt">.OrderDetails)<BR></SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">&nbsp;&nbsp;Dim</SPAN><SPAN style="mso-bidi-font-size: 10.0pt"> orderDetailsCount </SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">As</SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Integer</SPAN></FONT></FONT><SPAN style="mso-bidi-font-size: 10.0pt"><FONT face="Courier New,Courier,Monospace" size=2> = orderDetails.Count</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">&nbsp;&nbsp;Dim</SPAN><SPAN style="mso-bidi-font-size: 10.0pt"> counter </SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">As</SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Integer</SPAN></FONT></FONT><SPAN style="mso-bidi-font-size: 10.0pt"><FONT face="Courier New,Courier,Monospace" size=2> = 0</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">&nbsp;&nbsp;Do</SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">While</SPAN></FONT></FONT><SPAN style="mso-bidi-font-size: 10.0pt"><FONT face="Courier New,Courier,Monospace" size=2> counter &lt; orderDetailsCount</FONT><BR><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp;&nbsp;orderDetails(0).Delete()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counter += 1</FONT><BR></SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;Loop</FONT></SPAN><SPAN style="mso-bidi-font-size: 10.0pt"><BR></SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;MyBase</FONT></SPAN><SPAN style="mso-bidi-font-size: 10.0pt"><FONT face="Courier New,Courier,Monospace" size=2>.Delete()</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">End</SPAN><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt">Sub</SPAN><SPAN style="mso-bidi-font-size: 10.0pt"></FONT></FONT></FONT><FONT color=#000000><SPAN style="mso-bidi-font-size: 10.0pt"></FONT><SPAN style="mso-bidi-font-size: 10.0pt"></FONT></SPAN></SPAN></SPAN></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK6 hideFocus =0 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=0 width="100%"><T><TR><TD width="100%"><FONT face=Arial,Helvetica,sans-serif><FONT size=2><strong><DIV>&nbsp;</DIV><P>Calling Delete() on an Entity Cast to a DataRow</P></strong></FONT></FONT><P><FONT face=Arial,Helvetica,sans-serif size=2>Since Entity.Delete() shadows rather than overrides DataRow.Delete(), the developer must be aware that calling Delete() on a business object that has been cast to a DataRow will produce a different result than calling Delete() directly on the business object (in the case where Delete() has been overridden in the developer class). The former will only delete the specified DataRow itself, and will perform none of the supplementary actions coded into the Delete() override.<BR><BR>You could, for example, substitute for the following line from the above method:</FONT></P></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK10 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=3 width="100%"><T><TR><TD width="3%">&nbsp;</TD><TD width="97%"><P><strong><FONT face=Arial,Helvetica,sans-serif size=2>C#:</FONT></strong></P><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">base</SPAN><SPAN style="mso-no-proof: yes">.Delete();</SPAN></FONT></FONT></FONT><FONT color=#0000ff><BR><BR></FONT><P><BR><strong><FONT face=Arial,Helvetica,sans-serif size=2>VB.NET:</FONT></strong> </P><FONT color=#0000ff><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">MYbase</SPAN><FONT color=#000000><SPAN style="mso-no-proof: yes">.Delete();</SPAN></FONT></FONT></FONT></FONT> </TD></TR><TR><TD colSpan=2><FONT color=#0000ff><SPAN style="mso-bidi-font-size: 10.0pt"><FONT color=#000000><FONT face=Arial,Helvetica,sans-serif size=2>this one</FONT>:</FONT></SPAN></FONT></TD></TR><TR><TD>&nbsp;</TD><TD><P><strong><FONT face=Arial,Helvetica,sans-serif size=2>C#:</FONT></strong></P><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">((DataRow)</SPAN><SPAN style="mso-no-proof: yes">.Delete();</SPAN></FONT></FONT></FONT><FONT color=#0000ff><BR><BR></FONT><P><strong><FONT face=Arial,Helvetica,sans-serif size=2>VB.NET:</FONT></strong> </P><FONT color=#0000ff><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">CType(Me, DataRow)</SPAN><FONT color=#000000><SPAN style="mso-no-proof: yes">.Delete()</SPAN></FONT></FONT></FONT></FONT></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK8 hideFocus =0 cellSpacing=5 cellPadding=5 width="100%"><T><TR><TD align=middle><TABLE cellSpacing=0 cellPadding=3 width="100%"><T><TR><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Neither statement results in a recursive method call, since the referenced method, in both cases, is a different one from the one in which the statement resides.</FONT> <DIV><FONT face=Arial,Helvetica,sans-serif><FONT size=2><strong><DIV>&nbsp;</DIV>Providing a DeleteGraph() Method</strong><BR><BR>In this option you leave the Order class's Delete() method alone and provide a separate method to do your cascading deletes. We'll say here, for convenience, that we name this method DeleteGraph(), but you can of course call it whatever you like. Whatever its name, its operation will be as follows:</FONT></FONT></DIV></TD></TR><TR><TD width="3%"><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>1.</FONT></DIV></TD><TD width="97%"><FONT face=Arial,Helvetica,sans-serif size=2>Delete all desired related records, then</FONT></TD></TR><TR><TD><DIV align=center><FONT face=Arial,Helvetica,sans-serif size=2>2.</FONT></DIV></TD><TD><FONT face=Arial,Helvetica,sans-serif size=2>Delete the Order object itself</FONT></TD></TR><TR><TD colSpan=2><FONT face=Arial,Helvetica,sans-serif size=2>Such a method might look like the following (assuming for simplicity, that the OrderDetail objects are the only related objects to be deleted):</FONT></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK12 hideFocus =0 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=3 width="100%"><T><TR><TD width="3%">&nbsp;</TD><TD width="97%"><P><strong><FONT face=Arial,Helvetica,sans-serif size=2>C#:</FONT></strong></P><FONT size=2><FONT face="Courier New,Courier,Monospace"><FONT color=#0000ff>public </FONT><SPAN style="COLOR: blue; mso-no-proof: yes">int</SPAN></FONT></FONT><FONT size=2><FONT face="Courier New,Courier,Monospace"><SPAN style="mso-no-proof: yes"> DeleteGraph() {<BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">&nbsp;&nbsp;int</SPAN></FONT></FONT><FONT size=2><FONT face="Courier New,Courier,Monospace"><SPAN style="mso-no-proof: yes"> numberOfItemsDeleted = 0;<BR></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">&nbsp;&nbsp;EntityList</SPAN><SPAN style="mso-no-proof: yes">&lt;</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">OrderDetail</SPAN></FONT></FONT><FONT size=2><FONT face="Courier New,Courier,Monospace"><SPAN style="mso-no-proof: yes">&gt; orderDetails =<BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp;new</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">EntityList</SPAN><SPAN style="mso-no-proof: yes">&lt;</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">OrderDetail</SPAN><SPAN style="mso-no-proof: yes">&gt;(</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">this</SPAN></FONT></FONT><FONT size=2><FONT face="Courier New,Courier,Monospace"><SPAN style="mso-no-proof: yes">.OrderDetails);<BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">&nbsp;&nbsp;int</SPAN></FONT></FONT><FONT size=2><FONT face="Courier New,Courier,Monospace"><SPAN style="mso-no-proof: yes"> orderDetailsCount = orderDetails.Count;<BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">&nbsp;&nbsp;for</SPAN><SPAN style="mso-no-proof: yes"> (</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">int</SPAN></FONT></FONT><FONT size=2><FONT face="Courier New,Courier,Monospace"><SPAN style="mso-no-proof: yes"> counter = 0; counter &lt; orderDetailsCount;counter++){<BR></SPAN><SPAN style="mso-no-proof: yes">&nbsp;&nbsp;&nbsp;&nbsp;orderDetails&#091;0&#093;.Delete();</SPAN> <BR></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;}<BR></FONT></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;this</FONT></SPAN><FONT size=2><FONT face="Courier New,Courier,Monospace"><SPAN style="mso-no-proof: yes">.Delete();<BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">&nbsp;&nbsp;return</SPAN><SPAN style="mso-no-proof: yes"> (orderDetailsCount + 1);</SPAN><BR><SPAN style="mso-no-proof: yes">}</SPAN></FONT></FONT> <P><BR><strong><FONT face=Arial,Helvetica,sans-serif size=2>VB.NET:</FONT></strong> </P><FONT color=#0000ff><FONT face="Courier New,Courier,Monospace"><FONT size=2><FONT color=#000000>Public Function DeleteGraph() As Integer<BR></FONT>&nbsp;&nbsp;</FONT></FONT><FONT face="Courier New,Courier,Monospace" color=#000000 size=2>Dim numberOfItemsDeleted As Integer = 0<BR></FONT><FONT face="Courier New,Courier,Monospace" color=#000000 size=2>&nbsp;&nbsp;Dim orderDetails As EntityList(Of OrderDetail) = New EntityList(Of OrderDetail)(Me.OrderDetails)<BR>&nbsp;&nbsp;Dim orderDetailsCount As Integer = orderDetails.Count<BR>&nbsp;&nbsp;Dim counter As Integer = 0<BR>&nbsp;&nbsp;Do While counter &lt; orderDetailsCount<BR>&nbsp;&nbsp;&nbsp;&nbsp;orderDetails(0).Delete()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counter += 1<BR>&nbsp;&nbsp;Loop<BR>&nbsp;&nbsp;Me.Delete()<BR>&nbsp;&nbsp;Return (orderDetailsCount + 1)<BR>End Function</FONT></FONT></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK13 hideFocus =0 width="100%"><T><TR><TD><FONT face=Arial,Helvetica,sans-serif size=2>This method remains subject to the limitations previously discussed concerning other related OrderDetails that may exist but have not yet been retrieved into the local cache; but assuming you've covered that base to your satisfaction, it will do the job.&nbsp;To use it, you simply call</FONT> <TABLE cellSpacing=0 cellPadding=3 width="100%"><T><TR><TD width="3%">&nbsp;</TD><TD width="97%"><FONT face="Courier New,Courier,Monospace"><FONT size=2><FONT color=#0000ff><SPAN style="mso-no-proof: yes"><DIV>&nbsp;</DIV><P>currentOrder.DeleteGraph()</P><P></SPAN></FONT></FONT></FONT><FONT face=Arial,Helvetica,sans-serif size=2>instead of:</FONT><FONT face="Times New Roman"> </FONT><DIV>&nbsp;</DIV><DIV><FONT face="Courier New,Courier,Monospace" color=#0000ff size=2><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt"><SPAN style="mso-no-proof: yes">currentOrder.Delete()</SPAN></SPAN></FONT></DIV></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK11 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=0 width="100%"><T><TR><TD colSpan=2><P><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2>whenever you want the cascading delete.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>This is a simple and straightforward approach.</FONT></FONT></SPAN></P><FONT face=Arial,Helvetica,sans-serif><FONT size=2><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><strong>Provide a PersistenceManager Watcher</strong></SPAN><strong> </strong></FONT></FONT><P style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2>In this option you provide a class that watches the PersistenceManager for requests to delete Order objects, and intervenes before those deletions are consummated to delete the related child objects.<FONT color=#ff0000>**</FONT></FONT></FONT></P><P style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;</SPAN>It does the latter by means of a handler for the Order table's Row_Deleting event.</FONT></FONT></P><P style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2>The Row_Deleting handler is set up in the class's constructor.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In the implementation below, a Row_Deleted handler is also set up, and provides feedback on what occurred; but that is only for pedagogical purposes.</FONT></FONT></P></TD></TR><TR><TD width="9%"><FONT face=Arial,Helvetica,sans-serif size=2>&nbsp;</FONT></TD><TD width="91%"><FONT face=Arial,Helvetica,sans-serif><FONT size=2><FONT color=#ff0000>**</FONT> The class as shown here is only watching the Order table, and only for deletions; however, clearly its scope could be enlarged to include other tables and other operations</FONT></FONT></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK12 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=3 width="100%"><T><TR><TD width="3%"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;</FONT></TD><TD width="97%"><P><strong><FONT face=Arial,Helvetica,sans-serif size=2>C#:</FONT></strong></P><FONT color=#0000ff><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>using</FONT></SPAN><FONT face="Courier New,Courier,Monospace" color=#000000 size=2><SPAN style="mso-no-proof: yes"> System;<BR></SPAN></FONT><FONT color=#000000><SPAN style="mso-no-proof: yes"><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>using</FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> System.Collections.Generic;</FONT><BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>using</FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> System.Text;</FONT><BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>using</FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> System.Data;</FONT><BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>using</FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> System.Windows.Forms;</FONT><BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>using</FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> Model;</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">using</SPAN><SPAN style="mso-no-proof: yes"> IdeaBlade.Persistence;&nbsp;</SPAN></FONT></FONT></FONT> <P =CodeSnippet0><FONT color=#000000><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>namespace</FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> UI {</FONT><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp; </FONT></SPAN></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">class</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">PmWatcher</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> {</FONT><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">public</SPAN><SPAN style="mso-no-proof: yes"> PmWatcher(</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">PersistenceManager</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> pPersMgr) {</FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>mPersMgr = pPersMgr;</FONT></FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>SetWatchersForOrder();</FONT></FONT><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: green; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>//Could set watchers here for other tables, as desired</FONT><BR></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}&nbsp;</FONT></FONT></SPAN></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">private</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">void</SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"> SetWatchersForOrder() {<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: #2b91af; mso-no-proof: yes">DataTable</SPAN><SPAN style="mso-no-proof: yes"> orderTable = mPersMgr.GetTable(</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">typeof</SPAN><SPAN style="mso-no-proof: yes">(</SPAN><SPAN style="COLOR: #2b91af; mso-no-proof: yes">Order</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>));</FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;</SPAN>orderTable.RowDeleting +=<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></FONT></FONT></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">new</SPAN><SPAN style="COLOR: #2b91af; mso-no-proof: yes">DataRowChangeEventHandler</SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes">(OrderTable_RowDeleting);<BR>orderTable.RowDeleted +=</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">new </SPAN><SPAN style="COLOR: #2b91af; mso-no-proof: yes">DataRowChangeEventHandler</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>(OrderTable_RowDeleted);</FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}&nbsp;</FONT></FONT></SPAN></FONT></P><P =CodeSnippet0><FONT color=#000000><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>#region</FONT></FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> Row_Deleting Handler</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></SPAN><FONT color=#006633><SPAN style="mso-no-proof: yes">&lt;summary&gt;</SPAN></FONT></FONT></FONT><SPAN style="mso-no-proof: yes"><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></FONT></FONT></SPAN><SPAN style="COLOR: green; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> Delete related OrderDetail rows before consummating the delete of the targetted Order.</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></SPAN><FONT color=#006633><SPAN style="mso-no-proof: yes">&lt;/summary&gt;</SPAN></FONT></FONT></FONT><SPAN style="mso-no-proof: yes"><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">void</SPAN><SPAN style="mso-no-proof: yes"> OrderTable_RowDeleting(</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">object</SPAN><SPAN style="mso-no-proof: yes"> sender, </SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">DataRowChangeEventArgs</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> e) {<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>DeleteRelatedObjects(e);</FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}&nbsp;</FONT></FONT></SPAN></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">private</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">static</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">void</SPAN><SPAN style="mso-no-proof: yes"> DeleteRelatedObjects(</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">DataRowChangeEventArgs</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> e) {</FONT><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"> currentOrder = (</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes">)e.Row;<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">EntityList</SPAN><SPAN style="mso-no-proof: yes">&lt;</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">OrderDetail</SPAN><SPAN style="mso-no-proof: yes">&gt; orderDetails = </SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">new</SPAN><BR><SPAN style="COLOR: teal; mso-no-proof: yes">EntityList</SPAN><SPAN style="mso-no-proof: yes">&lt;</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">OrderDetail</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>&gt;(currentOrder.OrderDetails);</FONT><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>int</FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> orderDetailsCount = currentOrder.OrderDetails.Count;</FONT><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">for</SPAN><SPAN style="mso-no-proof: yes"> (</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">int</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> counter = 0; counter &lt; orderDetailsCount; counter++) {</FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>orderDetails&#091;0&#093;.Delete();<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</FONT></FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<BR></FONT></FONT></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>#endregion&nbsp;</FONT></FONT></SPAN></FONT></P><P =CodeSnippet0><FONT color=#000000><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>#region</FONT></FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> Row_Deleted Handler</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></SPAN><FONT color=#006633><SPAN style="mso-no-proof: yes">&lt;summary&gt;</SPAN></FONT></FONT></FONT><SPAN style="mso-no-proof: yes"><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></FONT></FONT></SPAN><SPAN style="COLOR: green; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> Report number of items in PM that are marked for deletion.</FONT><BR></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></FONT></FONT></SPAN><FONT color=#006633><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes">&lt;/summary&gt;<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>///</SPAN><SPAN style="mso-no-proof: yes">&lt;remarks&gt;</SPAN></FONT></FONT></FONT><SPAN style="mso-no-proof: yes"><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></FONT></FONT></SPAN><SPAN style="COLOR: green; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> This handler's action is intended simply for pedagogical purposes, to provide</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></SPAN></FONT></FONT><SPAN style="COLOR: green; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>feedback that the RowDeleting handler actually worked.</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><FONT color=#006633>///</FONT></SPAN><FONT color=#006633><SPAN style="mso-no-proof: yes">&lt;/remarks&gt;</SPAN></FONT></FONT></FONT><SPAN style="mso-no-proof: yes"><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">private</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">void</SPAN><SPAN style="mso-no-proof: yes"> OrderTable_RowDeleted(</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">object</SPAN><SPAN style="mso-no-proof: yes"> sender, </SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">DataRowChangeEventArgs</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2> e) {<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>DisplayCountOfRecordsDeleted();<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}&nbsp;</FONT></FONT></SPAN></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">private</SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">void</SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"> DisplayCountOfRecordsDeleted() {<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">EntityList</SPAN><SPAN style="mso-no-proof: yes">&lt;</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Entity</SPAN><SPAN style="mso-no-proof: yes">&gt; deletedEntities = </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">new<BR></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">EntityList</SPAN><SPAN style="mso-no-proof: yes">&lt;</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Entity</SPAN><SPAN style="mso-no-proof: yes">&gt;(mPersMgr.GetEntities(</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">DataRowState</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>.Deleted));</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">String</SPAN><SPAN style="mso-no-proof: yes"> msg = </SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">String</SPAN><SPAN style="mso-no-proof: yes">.Format(</SPAN><SPAN style="COLOR: maro&#111;n; mso-no-proof: yes">"Here in RowDeleted handler. "</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> +</FONT><BR><SPAN style="mso-spacerun: yes"><FONT face="Courier New,Courier,Monospace" size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: maro&#111;n; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>"There are now {0} records marked for deletion in the PM."</FONT></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes">,<BR>deletedEntities.Count.ToString());<BR><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">MessageBox</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>.Show(msg);</FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}</FONT></FONT><BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>#endregion&nbsp;</FONT></FONT></SPAN></FONT></P><P =CodeSnippet0><FONT color=#000000><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>#region</FONT></FONT></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> Private Fields</FONT><BR></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">PersistenceManager</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> mPersMgr;</FONT><BR></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>#endregion</FONT></FONT><BR></SPAN><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}</FONT></FONT><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2>}</FONT></FONT></SPAN></FONT><FONT color=#000000><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2> <BR></FONT></FONT></P></FONT><P><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><strong><FONT face=Arial,Helvetica,sans-serif>VB.NET:</FONT></strong> <FONT color=#0000ff>&nbsp; </FONT></FONT></FONT></P><FONT color=#0000ff><P =CodeSnippet0><SPAN style="COLOR: blue; mso-bidi-font-size: 10.0pt"><FONT color=#000000><P =CodeSnippet0><SPAN style="COLOR: blue"><FONT face="Courier New,Courier,Monospace" size=2>Imports</FONT></SPAN><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2> System<BR><SPAN style="COLOR: blue">Imports</SPAN> System.Collections.Generic<BR><SPAN style="COLOR: blue">Imports</SPAN> System.Text<BR><SPAN style="COLOR: blue">Imports</SPAN> System.Data<BR><SPAN style="COLOR: blue">Imports</SPAN> System.Windows.Forms<BR><SPAN style="COLOR: blue">Imports</SPAN> Model<BR><SPAN style="COLOR: blue">Imports</SPAN> IdeaBlade.Persistence&nbsp;</FONT></FONT></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue">Namespace</SPAN> UI<BR><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Friend</SPAN> <SPAN style="COLOR: blue">Class</SPAN> PmWatcher<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Public</SPAN> <SPAN style="COLOR: blue">Sub</SPAN> <SPAN style="COLOR: blue">New</SPAN>(<SPAN style="COLOR: blue">ByVal</SPAN> pPersMgr <SPAN style="COLOR: blue">As</SPAN> PersistenceManager)<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN>mPersMgr = pPersMgr<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>SetWatchersForOrder()<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">'Could set watchers here for other tables, as desired<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">Sub</SPAN>&nbsp;</FONT></FONT></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Private</SPAN> <SPAN style="COLOR: blue">Sub</SPAN> SetWatchersForOrder()<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Dim</SPAN> orderTable <SPAN style="COLOR: blue">As</SPAN> DataTable = mPersMgr.GetTable(<SPAN style="COLOR: blue">GetType</SPAN>(Order))<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">AddHandler</SPAN> orderTable.RowDeleting, <SPAN style="COLOR: blue">AddressOf</SPAN> OrderTable_RowDeleting<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">AddHandler</SPAN> orderTable.RowDeleted, <SPAN style="COLOR: blue">AddressOf</SPAN> OrderTable_RowDeleted<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">Sub</SPAN>&nbsp;</FONT></FONT></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">#Region</SPAN> "Row_Deleting Handler"<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' &lt;summary&gt;<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' Delete related OrderDetail rows before consummating the delete of the targetted Order.<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' &lt;/summary&gt;<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Private</SPAN> <SPAN style="COLOR: blue">Sub</SPAN> OrderTable_RowDeleting(<SPAN style="COLOR: blue">ByVal</SPAN> sender <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Object</SPAN>, <SPAN style="COLOR: blue">ByVal</SPAN> e <SPAN style="COLOR: blue">As</SPAN> DataRowChangeEventArgs)<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>DeleteRelatedObjects(e)<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">Sub</SPAN>&nbsp;</FONT></FONT></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Private</SPAN> <SPAN style="COLOR: blue">Shared</SPAN> <SPAN style="COLOR: blue">Sub</SPAN> DeleteRelatedObjects(<SPAN style="COLOR: blue">ByVal</SPAN> e <SPAN style="COLOR: blue">As</SPAN> DataRowChangeEventArgs)<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Dim</SPAN> currentOrder <SPAN style="COLOR: blue">As</SPAN> Order = <SPAN style="COLOR: blue">CType</SPAN>(e.Row, Order)<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Dim</SPAN> orderDetails <SPAN style="COLOR: blue">As</SPAN> EntityList(<SPAN style="COLOR: blue">Of</SPAN> OrderDetail) = <SPAN style="COLOR: blue">New</SPAN> EntityList(<SPAN style="COLOR: blue">Of</SPAN><BR>OrderDetail)(currentOrder.OrderDetails)<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Dim</SPAN> orderDetailsCount <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Integer</SPAN> = currentOrder.OrderDetails.Count<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Dim</SPAN> counter <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Integer</SPAN> = 0<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Do</SPAN> <SPAN style="COLOR: blue">While</SPAN> counter &lt; orderDetailsCount<BR><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>orderDetails(0).Delete()<BR><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>counter += 1<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue">Loop<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">End</SPAN> </FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue">Sub<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">#End Region</SPAN>&nbsp;</FONT></FONT></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">#Region</SPAN> "Row_Deleted Handler"<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' &lt;summary&gt;<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' Report number of items in PM that are marked for deletion.<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' &lt;/summary&gt;<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' &lt;remarks&gt;<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' This handler's action is intended simply for pedagogical purposes, to provide<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' feedback that the RowDeleting handler actually worked.<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: green">''' &lt;/remarks&gt;<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Private</SPAN> <SPAN style="COLOR: blue">Sub</SPAN> OrderTable_RowDeleted(<SPAN style="COLOR: blue">ByVal</SPAN> sender <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">Object</SPAN>, <SPAN style="COLOR: blue">ByVal</SPAN> e <SPAN style="COLOR: blue">As</SPAN> DataRowChangeEventArgs)<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>DisplayCountOfRecordsDeleted()<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">End</SPAN> <SPAN style="COLOR: blue">Sub</SPAN>&nbsp;</FONT></FONT></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Private</SPAN> <SPAN style="COLOR: blue">Sub</SPAN> DisplayCountOfRecordsDeleted()<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Dim</SPAN> deletedEntities <SPAN style="COLOR: blue">As</SPAN> EntityList(<SPAN style="COLOR: blue">Of</SPAN> Entity) = <SPAN style="COLOR: blue">New</SPAN> EntityList(</FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue">Of<BR></SPAN>Entity)(mPersMgr.GetEntities(DataRowState.Deleted))<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">Dim</SPAN> msg <SPAN style="COLOR: blue">As</SPAN> <SPAN style="COLOR: blue">String</SPAN> = <SPAN style="COLOR: blue">String</SPAN>.Format("Here in RowDeleted handler. " &amp; "There are now {0} records marked for deletion in the PM.", deletedEntities.Count.ToString())</FONT></FONT></FONT><FONT color=#000000><BR><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>MessageBox.Show(msg)<BR></FONT></FONT></FONT><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">End</SPAN> </FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue">Sub<BR></SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">#End Region</SPAN>&nbsp;</FONT></FONT></FONT></P><P =CodeSnippet0><FONT color=#000000><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">#Region</SPAN> "Private Fields"<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">Private</SPAN> mPersMgr <SPAN style="COLOR: blue">As</SPAN> PersistenceManager<BR><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN></FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue">#End Region<BR></SPAN><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">End</SPAN> </FONT></FONT><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue">Class<BR>End</SPAN> <SPAN style="COLOR: blue">Namespace</SPAN></FONT></FONT></FONT></P></FONT></SPAN><P></P></FONT></SPAN></SPAN></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK13 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=0 width="100%"><T><TR><TD width="100%"><P><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2>This watcher must be activated somewhere, before the Order deletions can be initiated.&nbsp;In the attached sample app ("CascadingDeleteWithPmWatcher") we have done so in the Form_Load event handler for the application's main form.&nbsp;That handler calls another method that issues the following statement:</FONT></FONT></SPAN></P></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK14 hideFocus =0 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=3 width="100%"><T><TR><TD width="3%">&nbsp;</TD><TD width="97%"><P><strong><FONT face=Arial,Helvetica,sans-serif size=2>C#:</FONT></strong></P><FONT face="Courier New, Courier, mono" color=#0000ff><P style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>mPmWatcher = </FONT></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">new</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">PmWatcher</SPAN><SPAN style="mso-no-proof: yes">(mPersMgr);</SPAN></FONT></FONT><SPAN style="mso-no-proof: yes"><BR></SPAN></P><P style="mso-bidi-font-weight: normal"><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2><strong><FONT color=#000000>VB.NET</FONT>:</strong></FONT></FONT></SPAN></P><P =CodeSnippet0><SPAN style="mso-no-proof: yes"><FONT face="Courier New,Courier,Monospace" size=2>mPmWatcher = </FONT></SPAN><FONT face="Courier New,Courier,Monospace"><FONT size=2><SPAN style="COLOR: blue; mso-no-proof: yes">New</SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">PmWatcher</SPAN><SPAN style="mso-no-proof: yes">(mPersMgr)</SPAN></FONT></FONT></P></FONT></TD></TR></T></TABLE></TD></TR></T></TABLE><TABLE id=c&#111;ntent_LETTER.BLOCK15 width="100%"><T><TR><TD><TABLE cellSpacing=0 cellPadding=0 width="100%"><T><TR><TD width="100%"><P><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2>where mPmWatcher was declared elsewhere at the class level.</FONT></FONT></SPAN></P><P style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif size=2>This approach to the problem has the advantage of leaving Delete() as the method to be used even for objects with related objects that need to be deleted.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>It also centralizes the exceptional delete logic, which you may consider either an advantage or a disadvantage, depending upon your perspective.</FONT></P><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><strong>Conclusion</strong></SPAN> </FONT></FONT><P style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT face=Arial,Helvetica,sans-serif><FONT size=2>None of the methods illustrated for implementing cascading deletes is clearly superior to the others for all circumstances.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Make your choice based on other factors in your development environment, or simply according to your personal taste.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>They all work!</FONT></FONT></P></SPAN></TD></TR></T></TABLE></TD></TR></T></TABLE>]]>
   </description>
   <pubDate>Mon, 09 Jul 2007 12:12:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=115&amp;PID=253#253</guid>
  </item> 
 </channel>
</rss>