<?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 : PersistenceManager.Clear() and EntityLists</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : PersistenceManager.Clear() and EntityLists</description>
  <pubDate>Fri, 12 Jun 2026 11:24:37 -700</pubDate>
  <lastBuildDate>Wed, 06 Jun 2007 13:13:27 -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=47</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>PersistenceManager.Clear() and EntityLists : Answer: You may have wondered...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=47&amp;PID=115#115</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> 47<br /><strong>Posted:</strong> 06-Jun-2007 at 1:13pm<br /><br /><P =Questi&#111;n style="MARGIN: 0in 0in 0pt"><strong><EM><FONT face="Times New Roman" size=3>Answer:</FONT></EM></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Times New Roman">You may have wondered why clearing a PM does not clear all EntityLists of the entities that live in that PM.<SPAN style="FONT-SIZE: 12pt"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>You've likely experienced this when&nbsp;a control or grid bound to an EntityList with entities in the cleared PM crashes.</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Times New Roman">Removing an entity from the PM does remove it from any EntityList that holds it, whether or not that EntityList is a managed list. All EntityLists remove detached entities when they see them become detached; you don't have to add a ListManager to enjoy this effect.<SPAN style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Times New Roman">However, clearing the PM (which turns all its entities into detached entities) does not cause the EntityList to update itself.<SPAN style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>The attached nunit test code demonstrates that fact and shows how to work around it (see ClearAllEntities).</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Times New Roman">We want to keep the current PM behavior because it is fast. An app that wants to clear a PM (rather than discard it) generally knows its EntityLists and can clear (or discard) them when it clears a PM. However, some apps are not designed to be sure that they know all of the EntityLists dependent on the PM. <SPAN style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>We have a feature request (as of January 2007) to provide an alternative to PersistenceManager.Clear() that will achieve this purpose more efficiently. </FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT size=2>&nbsp;<o:p></o:p></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt"><FONT size=2>UNIT TEST CODE AND WORKAROUND<o:p></o:p></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-SIZE: 12pt"><o:p><FONT face="Times New Roman">&nbsp;</FONT></o:p></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><BR></SPAN><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;Test that Clearing a PM also clears all EntityLists.&lt;/summary&gt;<BR>&nbsp;&nbsp;&nbsp; &#091;Test&#093;<BR>&nbsp;&nbsp;&nbsp; public void PmClearTest() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PersistenceManager pm = new PersistenceManager(PersistenceManager.DefaultManager);<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Read some entities so we can see what we're clearing;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityList&lt;Customer&gt; custList = pm.GetEntities&lt;Customer&gt;();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityList&lt;Order&gt; orderList = pm.GetEntities&lt;Order&gt;();<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityList&lt;Employee&gt; empList = new EntityList&lt;Employee&gt;();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; empList.ListChanged += new ListChangedEventHandler(empList_ListChanged); // listen for entities coming and going<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msListChangedContext = "initialize emplist"; // context in which list changed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; empList.ReplaceRange(pm.GetEntities&lt;Employee&gt;());<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int originalCount = empList.Count;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.Greater(originalCount, 0, "Got no emps.");<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><BR></SPAN><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msListChangedContext = "remove emp";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Employee anEmp = empList&#091;0&#093;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pm.RemoveEntity(anEmp, false);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.AreEqual(anEmp.RowState, DataRowState.Detached, "Removed emp is not detached.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.AreEqual(originalCount - 1, empList.Count, "Should have had one fewer emp after remove");<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; anEmp.AddToManager();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msListChangedContext = "re-add emp to manager and then to list";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; empList.Add(anEmp);<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;Defect:&nbsp;I think pm.Clear should&nbsp;be able to clear all EntityLists that it knows about automatically.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;Because it doesn't, we use ClearAllEntities to get the job done.<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6" face="Courier New" color=#808080 size=2><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Comment&nbsp;out the following 2 lines&nbsp;to see that PM doesn't clear the EntityLists and the tests fail.</strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6" face="Courier New" color=#808080 size=2><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msListChangedContext = null; // Don't report list changed for as its items disappear individually</strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClearAllEntities(pm); // Clear the PM entities first<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msListChangedContext = "clear pm."; // Never shown because no ListChanged event on Pm.Clear()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pm.Clear(); <SPAN style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.IsTrue(empList.Count == 0, "Have emps in EntityList after PM clear.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.IsTrue(custList.Count == 0, "Have customers in EntityList after PM clear.");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.IsTrue(orderList.Count == 0, "Have orders in EntityList after PM clear.");<BR>&nbsp;&nbsp;&nbsp; }<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; #region PmClearTest Diagnostic<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; private static string msListChangedContext = "Unknown context";<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; static void empList_ListChanged(object sender, ListChangedEventArgs e) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( String.IsNullOrEmpty(msListChangedContext) ) return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("ListChanged fired in context: " + msListChangedContext);<BR>&nbsp;&nbsp;&nbsp; }<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; #endregion<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; #region ClearAllEntities<BR>&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;Clears all entities in the Pm, also clearing associated EntityLists.&lt;/summary&gt;<BR>&nbsp;&nbsp;&nbsp; /// &lt;param name="pPm"&gt;The PersistenceManager we will clear.&lt;/param&gt;<BR>&nbsp;&nbsp;&nbsp; /// &lt;remarks&gt;<BR>&nbsp;&nbsp;&nbsp; /// This method is useful when we want to clear a PersistenceManager (PM)<BR>&nbsp;&nbsp;&nbsp; /// and do not know what EntityLists contain entities currently resident in that PM.<BR>&nbsp;&nbsp;&nbsp; /// &lt;para&gt;<BR>&nbsp;&nbsp;&nbsp; /// An EntityList(Of T) cannot clear itself today <BR>&nbsp;&nbsp;&nbsp; /// when we clear the PM holding entities in that list.<BR>&nbsp;&nbsp;&nbsp; /// An EntityList only listens for changes to the rowstate of individual entities,<BR>&nbsp;&nbsp;&nbsp; /// not to the EntityTable.TableCleared event.<BR>&nbsp;&nbsp;&nbsp; /// Moreover, PersistenceManager.Clear does not clear individual EntityTables;<BR>&nbsp;&nbsp;&nbsp; /// rather it simply discards the tables themselves.<BR>&nbsp;&nbsp;&nbsp; /// &lt;/para&gt;<BR>&nbsp;&nbsp;&nbsp; /// &lt;para&gt;<BR>&nbsp;&nbsp;&nbsp; /// This method iterates through all of the EntityTables of the PM<BR>&nbsp;&nbsp;&nbsp; /// and removes each entity of each table.<BR>&nbsp;&nbsp;&nbsp; /// &lt;/para&gt;<BR>&nbsp;&nbsp;&nbsp; /// &lt;para&gt;<BR>&nbsp;&nbsp;&nbsp; /// This could be very slow; it would be better to keep track of our<BR>&nbsp;&nbsp;&nbsp; /// EntityLists and clear them before clearing the PM.<BR>&nbsp;&nbsp;&nbsp; /// However, it may not be possible to know all of the EntityLists with<BR>&nbsp;&nbsp;&nbsp; /// entities in the PM we are clearing. <BR>&nbsp;&nbsp;&nbsp; /// This method will take care of that because all EntityLists<BR>&nbsp;&nbsp;&nbsp; /// will "hear" our removal of the individual entities.<BR>&nbsp;&nbsp;&nbsp; /// &lt;/para&gt;<BR>&nbsp;&nbsp;&nbsp; /// &lt;/remarks&gt;<BR>&nbsp;&nbsp;&nbsp; private void ClearAllEntities(PersistenceManager pPm) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pPm.QueryCache.Clear(); // Query cache should be empty after this operation<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataTableCollection pEntityTables = pPm.DataSet.Tables;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach ( DataTable anEntityTable in pEntityTables ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClearEntityTable(anEntityTable);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;Clears the entities of the type, T, in the Pm, also clearing associated EntityLists.&lt;/summary&gt;<BR>&nbsp;&nbsp;&nbsp; /// &lt;typeparam name="T"&gt;The entity type to clear.&lt;/typeparam&gt;<BR>&nbsp;&nbsp;&nbsp; /// &lt;param name="pPm"&gt;The PersistenceManager holding instances of this Entity type.&lt;/param&gt;<BR>&nbsp;&nbsp;&nbsp; private void ClearEntityType&lt;T&gt;(PersistenceManager pPm) where T : Entity {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityTable table = pPm.GetTable(typeof(T));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ClearEntityTable(table);<BR>&nbsp;&nbsp;&nbsp; }<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp; /// &lt;summary&gt;Clears the entities in the Entity table.&lt;/summary&gt;<BR>&nbsp;&nbsp;&nbsp; private static void ClearEntityTable(DataTable pEntityTable) {<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Diagnostic:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine("Clearing EntityTable: " + pEntityTable.TableName);<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // pEntityTable.Clear(); // doesn't work<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></strong></FONT></FONT></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New">&nbsp;<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><strong><FONT size=2><FONT color=#808080><FONT style=": #e6e6e6"><FONT face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // must remove each entity individually<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataRowCollection entities = pEntityTable.Rows;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ( int i = ( entities.Count - 1 ); i &gt;= 0; i-- ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entities.RemoveAt(i);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; #endregion<SPAN style="FONT-SIZE: 12pt; mso-bidi-font-size: 8.0pt"><o:p></o:p></SPAN></FONT></FONT></FONT></FONT></strong></P>]]>
   </description>
   <pubDate>Wed, 06 Jun 2007 13:13:27 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=47&amp;PID=115#115</guid>
  </item> 
  <item>
   <title>PersistenceManager.Clear() and EntityLists : Question: I&#8217;ve noticed that when...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=47&amp;PID=114#114</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=20" rel="nofollow">Customer</a><br /><strong>Subject:</strong> 47<br /><strong>Posted:</strong> 06-Jun-2007 at 1:11pm<br /><br /><P =Questi&#111;n style="MARGIN: 0in 0in 0pt"><strong><EM><FONT face="Times New Roman" size=3>Question:</FONT></EM></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Times New Roman">I’ve noticed that when I invoke PersistenceManager.Clear(), DevForce does not clear all EntityLists of the entities that live in that PM.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Why is that, and what can I do if I want them cleared?<SPAN style="FONT-SIZE: 12pt"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></FONT></P>]]>
   </description>
   <pubDate>Wed, 06 Jun 2007 13:11:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=47&amp;PID=114#114</guid>
  </item> 
 </channel>
</rss>