<?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 : Problem with Include</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Problem with Include</description>
  <pubDate>Sun, 12 Apr 2026 08:51:12 -700</pubDate>
  <lastBuildDate>Wed, 18 Jan 2012 20:29:15 -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=3217</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>Problem with Include : Hi DenisK,Thanks for your suggestion...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12489#12489</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1377" rel="nofollow">huy</a><br /><strong>Subject:</strong> 3217<br /><strong>Posted:</strong> 18-Jan-2012 at 8:29pm<br /><br />Hi DenisK,<div><br>Thanks for your suggestion but I'm affraid I can't implement it that way. Although refetch works perfectly but it only gets one entity type at a time. If your root entity has 5 relations, you will need to call refetch 5 times. I tried to refetch a batch of entities of different type in one call but it still makes differents calls for each type.</div><div><br></div><div>The requirement is minimizing the server side queries while maintaining the "up to date" version of data.</div><div><br></div><div>Finally, I was able to implement it to meet the requirement.</div><div><br></div><div>Thanks for your support.</div>]]>
   </description>
   <pubDate>Wed, 18 Jan 2012 20:29:15 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12489#12489</guid>
  </item> 
  <item>
   <title>Problem with Include :  Ah I see what you&amp;#039;re asking...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12486#12486</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> 3217<br /><strong>Posted:</strong> 18-Jan-2012 at 4:57pm<br /><br />Ah I see what you're asking now. Yes, there's a way to refresh your cache by calling EntityManager.RefetchEntities.<div><br></div><div><a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/forced-refetch-query" target="_blank">http://drc.ideablade.com/xwiki/bin/view/Documentation/forced-refetch-query</a>&nbsp;<br><div><br></div><div>Consider the following example below.</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>&nbsp; &nbsp; &nbsp; //Create 1 EntityManager called mgr1. Prime it with 1 customer and 1 order</div><div>&nbsp; &nbsp; &nbsp; var mgr1 = new NorthwindIBEntities();</div><div>&nbsp; &nbsp; &nbsp; var newCust = CreateTestCustomer(mgr1);</div><div>&nbsp; &nbsp; &nbsp; var newOrder = CreateTestOrder(mgr1);</div><div>&nbsp; &nbsp; &nbsp; newCust.OrderSummaries.Add(newOrder);</div><div>&nbsp; &nbsp; &nbsp; mgr1.SaveChanges();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //Create another EntityManager called mgr2. Query the newly created customer</div><div>&nbsp; &nbsp; &nbsp; var mgr2 = new NorthwindIBEntities();</div><div>&nbsp; &nbsp; &nbsp; var newCust2 = mgr2.Customers.Where(c =&gt; c.Id == newCust.Id).Include(c =&gt; c.OrderSummaries).FirstOrNullEntity();</div><div>&nbsp; &nbsp; &nbsp; var newOrder2 = newCust2.OrderSummaries.FirstOrDefault();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //Delete the order</div><div>&nbsp; &nbsp; &nbsp; newOrder2.EntityAspect.Delete();</div><div>&nbsp; &nbsp; &nbsp; mgr2.SaveChanges();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //Refresh mgr1 by calling RefetchEntities</div><div>&nbsp; &nbsp; &nbsp; mgr1.RefetchEntities(newCust.OrderSummaries, MergeStrategy.OverwriteChanges);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //Now verify that order has indeed been deleted</div><div>&nbsp; &nbsp; &nbsp; Assert.IsTrue(newOrder.EntityAspect.EntityState.IsDetached());</div><div>&nbsp; &nbsp; &nbsp; Assert.IsTrue(newCust2.OrderSummaries.Count == 0);</div></div><div></pre></td></tr></table></div></div><span style="font-size:10px"><br /><br />Edited by DenisK - 18-Jan-2012 at 4:58pm</span>]]>
   </description>
   <pubDate>Wed, 18 Jan 2012 16:57:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12486#12486</guid>
  </item> 
  <item>
   <title>Problem with Include : Hi DenisK,Yes, I understand what...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12485#12485</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1377" rel="nofollow">huy</a><br /><strong>Subject:</strong> 3217<br /><strong>Posted:</strong> 18-Jan-2012 at 4:09pm<br /><br />Hi DenisK,<div><br></div><div>Yes, I understand what you mean, no one will delete records at&nbsp;<span style=": rgb251, 251, 253; text-align: left; ">Management&nbsp;</span>Studio level but this is very common in multi users environment. If a user uses your application to delete a record, you will have the same problem on your side.</div><div><br></div><div>Clearing the cache is ok but it is not what I expect. I want my application has such behavior.</div><div><br></div><div>When a user open a Customer detail screen, for instance, it will first check this Customer if it exists in cache.</div><div>If yes, it will show the screen with the cached version of this Customer and run a query with DataSource stragety to refresh data.</div><div>If No, it will get data from DataSource and then show to user.</div><div>If we have error from getting data from server, the user can still work with the cached version of the Customer.</div><div><br></div><div>Clearing the cache will disable this idea and will show empty data or raise error. Moreover, the application will not have "Offline" feature, the main reason that we choose to use DevForce.</div><div><br></div><div>Is there anyway to access related entities that are queried along with the root entity using "Include" to pre-process them before they are merged with the EntityManager's cache?</div>]]>
   </description>
   <pubDate>Wed, 18 Jan 2012 16:09:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12485#12485</guid>
  </item> 
  <item>
   <title>Problem with Include : Hi huy,This is the correct behavior...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12481#12481</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> 3217<br /><strong>Posted:</strong> 18-Jan-2012 at 11:24am<br /><br />Hi huy,<div><br></div><div>This is the correct behavior because when you delete an order using the Management Studio, you're not using DevForce to mark the order deleted so the second query actually retrieves 4 but since the deleted order is still in the cache, you're seeing 5.</div><div><br></div><div>To handle this properly, you can refresh your EntityManager's cache by clearing it ( EntityManager.Clear () ) and then re-query.</div><div><br></div><div>Please note that when you build your application, you probably don't want your users to delete any record using the Management Studio.</div><div><br></div><div>Please see this page,&nbsp;<a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/create-modify-delete" target="_blank">http://drc.ideablade.com/xwiki/bin/view/Documentation/create-modify-delete</a>, to help you understand how to do CUD (Create, Update/Modify, Delete) operations using DevForce.</div><div><br></div><div>Hope this helps.</div>]]>
   </description>
   <pubDate>Wed, 18 Jan 2012 11:24:46 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12481#12481</guid>
  </item> 
  <item>
   <title>Problem with Include : Hi,Say I&amp;#039;d like to do a query...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12470#12470</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1377" rel="nofollow">huy</a><br /><strong>Subject:</strong> 3217<br /><strong>Posted:</strong> 16-Jan-2012 at 1:46am<br /><br />Hi,<div><br></div><div>Say I'd like to do a query like this:</div><div>_manager.Customers.Where(c =&gt; c.Id == 10).Include("Orders").With(QueryStrategy.DataSourceThenCache);</div><div><br></div><div>The first time it run well, I should have a customer id = 10 and 5 Orders, for instance.</div><div>Then I delete an Order using SQL Server Management Studio and run the query again.</div><div><br></div><div>I still got 5 Orders instead of 4. I think it is related to entity cache but I don't know how to handle it properly.</div><div><br></div><div>Could you please help me ?</div>]]>
   </description>
   <pubDate>Mon, 16 Jan 2012 01:46:20 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3217&amp;PID=12470#12470</guid>
  </item> 
 </channel>
</rss>