<?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 : Saving a deleted entity</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Saving a deleted entity</description>
  <pubDate>Sun, 12 Apr 2026 02:28:43 -700</pubDate>
  <lastBuildDate>Wed, 08 Aug 2007 12:19:10 -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=359</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>Saving a deleted entity :  The standard way to save just...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=359&amp;PID=887#887</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> 359<br /><strong>Posted:</strong> 08-Aug-2007 at 12:19pm<br /><br /><FONT face=Arial color=#000080 size=2><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT color=#000000><FONT face="Times New Roman">The standard way to save just a few entities is to populate an EntityList with only the entities that you want to save, and then call:<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT color=#000000><FONT face="Times New Roman">SaveChanges(AnEntityList);<o:p></o:p></FONT></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT color=#000000><FONT face="Times New Roman">Where AnEntityList is an instance on an EntityList.<o:p></o:p></FONT></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT color=#000000><FONT face="Times New Roman">The thing that is a little tricky is saving a deleted entity&nbsp; (i.e., deleting an entity from the database).&nbsp; If you&nbsp; delete an entity, then populate an EntityList with the deleted entity, and finally call SaveChanges on the EntityList, you will find that the entity does not get deleted from the database.&nbsp; The reason for this is that the default behavior of an EntityList is to remove any deleted entities.&nbsp; To override this behavior, set the </FONT><SPAN style="FONT-FAMILY: 'Courier New'">ShouldRemoveDeletedEntities </SPAN><FONT face="Times New Roman">property of the EntityList to false.<o:p></o:p></FONT></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT color=#000000><FONT face="Times New Roman">Here is a code sample that will delete the currently selected Employee from the database: <o:p></o:p></FONT></FONT></FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><FONT size=3><FONT color=#000000>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</FONT><SPAN style="COLOR: #2b91af">Employee</SPAN><FONT color=#000000> aEmployee = (</FONT><SPAN style="COLOR: #2b91af">Employee</SPAN><FONT color=#000000>)mEmpSource.Current;<o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><FONT size=3><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT><SPAN style="COLOR: #2b91af">EntityList</SPAN><FONT color=#000000>&lt;</FONT><SPAN style="COLOR: #2b91af">Employee</SPAN><FONT color=#000000>&gt; aDeletedEmployeeList = </FONT><SPAN style="COLOR: blue">new</SPAN><FONT color=#000000> </FONT><SPAN style="COLOR: #2b91af">EntityList</SPAN><FONT color=#000000>&lt;</FONT><SPAN style="COLOR: #2b91af">Employee</SPAN><FONT color=#000000>&gt;();<o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><FONT size=3><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aDeletedEmployeeList.Add(aEmployee);<o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><FONT size=3><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aDeletedEmployeeList.ShouldRemoveDeletedEntities = </FONT><SPAN style="COLOR: blue">false</SPAN><FONT color=#000000>;<o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><FONT size=3><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aEmployee.Delete();<o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><FONT size=3><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mPM.SaveChanges(aDeletedEmployeeList);<o:p></o:p></FONT></FONT></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Courier New'"><o:p><FONT color=#000000 size=3>&nbsp;</FONT></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" color=#000000 size=3>&nbsp;</FONT></o:p></P><P></FONT>&nbsp;</P>]]>
   </description>
   <pubDate>Wed, 08 Aug 2007 12:19:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=359&amp;PID=887#887</guid>
  </item> 
  <item>
   <title>Saving a deleted entity : I am trying to save one entity...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=359&amp;PID=886#886</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> 359<br /><strong>Posted:</strong> 08-Aug-2007 at 12:16pm<br /><br /><P =Ms&#111;normal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">I am trying to save one entity only.<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></P><P =Ms&#111;normal><FONT face=Arial color=navy size=2><SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">I tred to use: </SPAN></FONT><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">_msManager.SaveChanges(myentity), but that does not work.<o:p></o:p></SPAN></FONT></P><P =Ms&#111;normal><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">I tried : _msManager.SaveChanges(myentity.ToArray()), but that does not work with deleted rows.<o:p></o:p></SPAN></FONT></P><P =Ms&#111;normal><FONT face="Courier New" size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Do you have a suggestion?<o:p></o:p></SPAN></FONT></P>]]>
   </description>
   <pubDate>Wed, 08 Aug 2007 12:16:41 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=359&amp;PID=886#886</guid>
  </item> 
 </channel>
</rss>