<?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 : Question about entity manager cache &amp; top x queries</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Question about entity manager cache &amp; top x queries</description>
  <pubDate>Wed, 10 Jun 2026 12:54:36 -700</pubDate>
  <lastBuildDate>Wed, 09 Jun 2010 13:36:26 -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=1870</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>Question about entity manager cache &amp; top x queries : When a query has a non-zero Top...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7230#7230</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> 1870<br /><strong>Posted:</strong> 09-Jun-2010 at 1:36pm<br /><br /><P =Ms&#111;normal><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">When a query has a non-zero Top operator it’s not saved to the QueryCache.<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P><P =Ms&#111;normal><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p></o:p></SPAN></P><P =Ms&#111;normal><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">So, for the questions in the first post&nbsp; -<o:p></o:p></SPAN></P><P style="MARGIN-LEFT: 4.5pt"><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">EntityQuery eq = new IdeaBlade.Persistence.EntityQuery(typeof(SomeEntity));<o:p></o:p></SPAN></P><P style="MARGIN-LEFT: 4.5pt"><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">eq.Top = 50;<o:p></o:p></SPAN></P><P style="MARGIN-LEFT: 4.5pt"><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">_PMCentral.GetEntities&lt;T&gt;(eq,QueryStrategy.Normal)<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN-LEFT: 4.5pt"><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">This will go back to datasource each time it’s run because the query wasn’t placed in the QueryCache.<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN-LEFT: 4.5pt"><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p>&nbsp;</o:p></SPAN><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Second part - <o:p></o:p></SPAN></P><P><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">EntityQuery eq = new IdeaBlade.Persistence.EntityQuery(typeof(SomeEntity));<o:p></o:p></SPAN></P><P><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">eq.Top = 0;<o:p></o:p></SPAN></P><P><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">_PMCentral.GetEntities&lt;T&gt;(eq,QueryStrategy.Normal)<o:p></o:p></SPAN></P><P><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">eq.Top = 50;<o:p></o:p></SPAN></P><P><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'">_PMCentral.GetEntities&lt;T&gt;(eq,QueryStrategy.Normal) <o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN-LEFT: 4.5pt"><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">The first query was added to the QueryCache because the Top operator was 0.&nbsp; On subsequent execution, even though the Top operator has now been set to 50, DevForce will first look in the QueryCache to see if the query has been executed.&nbsp; It finds the query, and runs the query against cache, applying the Top operator locally.<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN-LEFT: 4.5pt"><SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p>&nbsp;</o:p></SPAN></P>]]>
   </description>
   <pubDate>Wed, 09 Jun 2010 13:36:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7230#7230</guid>
  </item> 
  <item>
   <title>Question about entity manager cache &amp; top x queries : Hi David  Thank you for your...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7220#7220</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=808" rel="nofollow">gepi</a><br /><strong>Subject:</strong> 1870<br /><strong>Posted:</strong> 09-Jun-2010 at 7:12am<br /><br />Hi David<DIV>&nbsp;</DIV><DIV>Thank you for your fast answer. </DIV><DIV>&nbsp;</DIV><DIV>Unfortunally I do not use a PaaThruQuery. It is a normal EntityQuery in which I set the Top property. </DIV><DIV>It seems that there is a difference&nbsp;between queries, in which the Top property is set, and in which this property is set to 0:</DIV><DIV>When I set the Top property, the query is not&nbsp;added to the&nbsp;QueryCache and it always fetches the data form the database (except I use the CacheOnly Query Strategy).</DIV><DIV>&nbsp;</DIV><DIV>If I run the same query without setting this property than everything is fine - the second time&nbsp;I run the query the data are fetched from cache.</DIV><DIV>&nbsp;</DIV><DIV>kind regards</DIV><DIV>&nbsp;</DIV><DIV>Georg</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 09 Jun 2010 07:12:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7220#7220</guid>
  </item> 
  <item>
   <title>Question about entity manager cache &amp; top x queries : If you had written the query in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7201#7201</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> 1870<br /><strong>Posted:</strong> 08-Jun-2010 at 11:02am<br /><br />If you had written the query in OQL, the PersistenceManager would have found the entities in the cache. but you can't use TOP in OQL.&nbsp; The Developer's Guide says:<DIV><FONT size=3></FONT>&nbsp;</DIV><DIV><FONT size=3><strong><EM>OQL Limitations </EM></strong></DIV></FONT><FONT size=2><P><strong><EM>OQL can cover most of the searches we need. There are useful queries that we can&#8223;t express in OQL. </EM></strong></P><P><strong><EM>OQL queries always return business objects. Therefore, OQL cannot express a query with a result that does not map to business object. </EM></strong></P><P><strong><EM>This restriction eliminates any query that describes the fields of a </EM></strong></FONT><strong><EM><FONT face="Lucida C&#111;nsole,Lucida C&#111;nsole" size=1><FONT face="Lucida C&#111;nsole,Lucida C&#111;nsole" size=1>Select </FONT></FONT><FONT size=2>statement. We can&#8223;t choose to return just the &#091;FirstName&#093; but not the &#091;LastName&#093; because an Employee object expects both. Aggregates (sum, min, max, average, etc.) and calculated fields are out</FONT><FONT size=1>94</FONT></EM></strong><FONT size=2><strong><EM>. </EM></strong></P><P><strong><EM>We can&#8223;t write OQL equivalents to SQL statements that include: </EM></strong></P><P><strong><EM>calculated comparisons (</EM></strong></FONT><FONT face="Lucida C&#111;nsole,Lucida C&#111;nsole" size=1><FONT face="Lucida C&#111;nsole,Lucida C&#111;nsole" size=1><strong><EM>PriceEntityColumn x QuantityEntityColumn &gt; 100</EM></strong></FONT></FONT><FONT size=2><strong><EM>) </EM></strong></P><P><strong><EM>GROUP BY and HAVING clauses ("orders with more than 3 items") </EM></strong></P><P><strong><EM>ANY and ALL </EM></strong></P><P><strong><EM>UNION </EM></strong></P><P><strong><EM>TOP </EM></strong></P><DIV></DIV><P>Therefore, I am assuming that you used a PassThruQuery, and the PersistenceManager does not cache the results of a PassThruQuery.</P><DIV></DIV></FONT>]]>
   </description>
   <pubDate>Tue, 08 Jun 2010 11:02:22 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7201#7201</guid>
  </item> 
  <item>
   <title>Question about entity manager cache &amp; top x queries : Hi I have the following code:EntityQuery...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7198#7198</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=808" rel="nofollow">gepi</a><br /><strong>Subject:</strong> 1870<br /><strong>Posted:</strong> 08-Jun-2010 at 3:53am<br /><br /><P>Hi <BR>&nbsp;<BR>I have the following code:<BR>&nbsp;<BR>EntityQuery eq = new IdeaBlade.Persistence.EntityQuery(typeof(SomeEntity));</P><P>eq.Top = 50;</P><P>_PMCentral.GetEntities&lt;T&gt;(eq,QueryStrategy.Normal)</P><P>this works fine, but every time I run this query (in an session) it fetches the data form the database.It never fetches the data form the cache. <BR>My understanding of the&nbsp; Persistancemanager Cache is that it should fetch the data the first time form the DataSource, the times after it should fetch it from the cache. Is this right? <BR>&nbsp;<BR>The other point is that if run this sequence:<BR>EntityQuery eq = new IdeaBlade.Persistence.EntityQuery(typeof(SomeEntity));</P><P>eq.Top = 0;</P><P>_PMCentral.GetEntities&lt;T&gt;(eq,QueryStrategy.Normal)</P><P>eq.Top = 50;</P><P>_PMCentral.GetEntities&lt;T&gt;(eq,QueryStrategy.Normal) </P><P>than the second query is fetching its data from the cache.<BR>&nbsp;<BR>is there a special behavior for "top" query? <BR>Do I miss something?<BR>&nbsp;<BR>kind regards</P>]]>
   </description>
   <pubDate>Tue, 08 Jun 2010 03:53:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1870&amp;PID=7198#7198</guid>
  </item> 
 </channel>
</rss>