<?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 : Skip, Take and Count</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Skip, Take and Count</description>
  <pubDate>Sun, 12 Apr 2026 05:54:58 -700</pubDate>
  <lastBuildDate>Thu, 25 Aug 2011 12:05:17 -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=2922</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>Skip, Take and Count :   Mickan,Projections will return...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11527#11527</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2922<br /><strong>Posted:</strong> 25-Aug-2011 at 12:05pm<br /><br />Mickan,<div>&nbsp;</div><div>Projections will return only the entity part you selected (not the entire entity). There is an article in the <a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/query-an&#111;nymous-projecti&#111;ns" target="_blank">DevForce Resource Center</a> that explains this topic in detail.</div><div>&nbsp;</div><div>When working n-tier, no entities will be loaded into the BOS when returning a count.</div><div>&nbsp;</div><div>Silvio.</div>]]>
   </description>
   <pubDate>Thu, 25 Aug 2011 12:05:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11527#11527</guid>
  </item> 
  <item>
   <title>Skip, Take and Count : Silvio, thanks thats very helpful,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11526#11526</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1132" rel="nofollow">mickan</a><br /><strong>Subject:</strong> 2922<br /><strong>Posted:</strong> 25-Aug-2011 at 11:13am<br /><br />Silvio, thanks thats very helpful, especially the code sample.&nbsp;&nbsp; To dig a little deeper:<DIV>&nbsp;</DIV><DIV>Do projections behave the same way, or will they result in data row transfer?</DIV><DIV>With a BOS involved, will there be data row retrival into the BOS in either of the entity or projection cases when returning a count?</DIV>]]>
   </description>
   <pubDate>Thu, 25 Aug 2011 11:13:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11526#11526</guid>
  </item> 
  <item>
   <title>Skip, Take and Count :   Hi mickan,Yes, Count() causes...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11525#11525</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2922<br /><strong>Posted:</strong> 25-Aug-2011 at 10:53am<br /><br />Hi mickan,<div>&nbsp;</div><div>Yes, Count() causes immediate execution of the query, but that doesn't mean that all the records have been returned to the client.</div><div>&nbsp;</div><div>You can verify that:</div><div>&nbsp;</div><div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp; mgr.Clear();</font></font></div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">&nbsp; var</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> ordersCount = mgr.Orders.Count(); <font color="#008000" size="2" face="C&#111;nsolas"><font color="#008000" size="2" face="C&#111;nsolas"><font color="#008000" size="2" face="C&#111;nsolas">// will return the number of Orders in the datasource</font></font></font></font></font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp;&nbsp;</font></font><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">var</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> orders = mgr.Orders.With(</font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">QueryStrategy</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">.CacheOnly).Execute(); <font color="#008000">// will be empty because no Orders were loaded in the client</font></font></font></div></div><div>&nbsp;</div><div>or, if working asynchronously:</div><div>&nbsp;</div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp; mgr.Clear();</font></font></div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">&nbsp; var</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> ordersCountOp = mgr.Orders.AsScalarAsync().Count();</font></font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp; ordersCountOp.Completed += (o, args) =&gt; {</font></font></div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; var</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> ordersCount = ordersCountOp.Result; <font color="#008000">// will return the number of Orders in the datasource</font></font></font></div><div><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas"><font color="#0000ff" size="2" face="C&#111;nsolas">&nbsp;&nbsp;&nbsp; var</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> orders = mgr.Orders.With(</font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">QueryStrategy</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">.CacheOnly).Execute(); <font color="#008000">// will be empty because no Orders were loaded in the client</font></font></font></div><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&nbsp; };</font></font></div><div>&nbsp;</div><div>To answer your questions:</div><div>1. Only the requested rows will be transfered from the data source.</div><div>2. Not necessary. (given explanation about Count() above)</div><div>3. If you are retriving a really large number of records and it's causing your app to 'hang' during this retrieval, I'd suggest issuing 2 queries: one for the records that will populate the first grid page and other for all records.</div><div>&nbsp;</div><div>Regards,</div><div>&nbsp;&nbsp; Silvio.</div>]]>
   </description>
   <pubDate>Thu, 25 Aug 2011 10:53:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11525#11525</guid>
  </item> 
  <item>
   <title>Skip, Take and Count : From what I&amp;#039;ve read on the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11512#11512</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1132" rel="nofollow">mickan</a><br /><strong>Subject:</strong> 2922<br /><strong>Posted:</strong> 24-Aug-2011 at 7:26am<br /><br />From what I've read on the board I think I understand that the linq Count() operation causes immediate execution of the query.&nbsp; So if the query was to return thousands of rows that would be "unfortunate" for the user, especially over a wan.<DIV>&nbsp;</DIV><DIV>I can use Skip() and Take() to chunk the data retrieval, but my Xceed grid wants a count of possible records, presumably to display the thumb slider at an appropriate size and do other housekeeping for "virtualizing" the data presentation.</DIV><DIV>&nbsp;</DIV><DIV>So my questions are:</DIV><DIV>&nbsp;</DIV><DIV>1. Are skip() and take() executed in the BOS so that only the requested rows get transferred from the data source?</DIV><DIV>2. Is requesting an implementation of a linq extension, say ToCount(), a reasonable&nbsp;ask of the DevForce linq provider?</DIV><DIV>3. Any better suggestions for me than having two methods for potentially large queries in my repository, such as </DIV><DIV>&nbsp;</DIV><DIV>IList GetLotsOfEntities();</DIV><DIV>int&nbsp;&nbsp;&nbsp; GetLotsOfEntitiesCount();</DIV>]]>
   </description>
   <pubDate>Wed, 24 Aug 2011 07:26:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2922&amp;PID=11512#11512</guid>
  </item> 
 </channel>
</rss>