<?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 : Deleting child entities from generic entity. How?</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Deleting child entities from generic entity. How?</description>
  <pubDate>Wed, 13 May 2026 06:26:22 -700</pubDate>
  <lastBuildDate>Thu, 12 Apr 2012 06:23:53 -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=3388</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>Deleting child entities from generic entity. How? :   That works. Thank you! </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13288#13288</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3388<br /><strong>Posted:</strong> 12-Apr-2012 at 6:23am<br /><br />That works. Thank you!]]>
   </description>
   <pubDate>Thu, 12 Apr 2012 06:23:53 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13288#13288</guid>
  </item> 
  <item>
   <title>Deleting child entities from generic entity. How? : Hi katit,Instead of using reflection,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13287#13287</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3388<br /><strong>Posted:</strong> 12-Apr-2012 at 1:11am<br /><br />Hi katit,<div><br></div><div>Instead of using reflection, consider using DevForce entity metadata. For example,</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>&nbsp; &nbsp; private void DeleteEntityFromEntityManager(Entity entity) {</div><div>&nbsp; &nbsp; &nbsp; foreach (var listNavigationProperty in entity.EntityAspect.EntityMetadata.ListNavigationProperties) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var childrens = listNavigationProperty.GetValue(entity) as IEnumerable&lt;Entity&gt;;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; childrens.ToList().ForEach(c =&gt; c.EntityAspect.Delete());</div><div>&nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div></div><div></pre></td></tr></table></div><div><br></div><div>Hope this helps.</div>]]>
   </description>
   <pubDate>Thu, 12 Apr 2012 01:11:22 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13287#13287</guid>
  </item> 
  <item>
   <title>Deleting child entities from generic entity. How? :   Actually, I made it work with...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13285#13285</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3388<br /><strong>Posted:</strong> 11-Apr-2012 at 1:19pm<br /><br />Actually, I made it work with reflection like this:<div>&nbsp;</div><div>public void DeleteEntityFromManager(T entity)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entity.EntityAspect.Delete();</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (this.EntitiesToDeleteWhenDeleting == null || !this.EntitiesToDeleteWhenDeleting.Any()) return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var entitiesToDelete in this.EntitiesToDeleteWhenDeleting)<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; var property = entity.GetType().GetProperty(entitiesToDelete);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var childEntities = property.GetValue(entity, null) as IEnumerable&lt;Entity&gt;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (childEntities != null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var childEntity in childEntities)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; childEntity.EntityAspect.Delete();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;</div><div>Does it look like a good solution or it can be done better?</div>]]>
   </description>
   <pubDate>Wed, 11 Apr 2012 13:19:37 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13285#13285</guid>
  </item> 
  <item>
   <title>Deleting child entities from generic entity. How? :    I have base repository that...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13282#13282</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3388<br /><strong>Posted:</strong> 11-Apr-2012 at 11:59am<br /><br /><div>I have base repository that does most entity work on Silverlight client.</div><div>&nbsp;</div><div>Consider this:</div><div>&nbsp;</div><div>public void DeleteEntityFromManager(T entity)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entity.EntityAspect.Delete();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (this.EntitiesToDeleteWhenDeleting != null &amp;&amp; this.EntitiesToDeleteWhenDeleting.Any())<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; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var entitiesToEnclude in this.EntitiesToIncludeWhenLoading) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query = query.Include(entitiesToEnclude);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;</div><div>"If" statement inside function doesn't work right now, I just copied it from my generic "Query". When I do generic query - I append includes like this:</div><div>&nbsp;</div><div>var query = EntityQuery.Create(typeof(T), this.EntityManager).OrderBySelector(sortSelector);</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (this.EntitiesToIncludeWhenLoading != null &amp;&amp; this.EntitiesToIncludeWhenLoading.Any())<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; foreach (var entitiesToEnclude in this.EntitiesToIncludeWhenLoading) query = query.Include(entitiesToEnclude);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;</div><div>So, going back to my example on top - I'd like to somehow delete child entities according to <strong>EntitiesToDeleteWhenDeleting</strong> content&nbsp;which is just IEnumerable&lt;string&gt; and it can be something like "Users".</div><span style="font-size:10px"><br /><br />Edited by katit - 11-Apr-2012 at 12:00pm</span>]]>
   </description>
   <pubDate>Wed, 11 Apr 2012 11:59:49 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3388&amp;PID=13282#13282</guid>
  </item> 
 </channel>
</rss>