<?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 : Devforce Queries and IQueryable&lt;T&gt;.Count()</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Devforce Queries and IQueryable&lt;T&gt;.Count()</description>
  <pubDate>Sat, 11 Apr 2026 22:19:04 -700</pubDate>
  <lastBuildDate>Tue, 26 May 2009 11:03:39 -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=1280</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>Devforce Queries and IQueryable&lt;T&gt;.Count() : This behavior is by design. An...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1280&amp;PID=4643#4643</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1280<br /><strong>Posted:</strong> 26-May-2009 at 11:03am<br /><br />This behavior is by design.&nbsp;&nbsp; An "immediate execution" type of query (such as Count(), Max(), First()) which returns a number or other scalar can only be meaningfully executed against cache or the data source, but not a combination.&nbsp; In this case if we tried the usual DataSourceThenCache behavior and, for example, found 77 in the database and 78 in cache, what would the union of these two numbers mean?&nbsp;&nbsp; When the QueryStrategy is "Normal" queries such as this actually resolve to using a DataSourceOnly fetch strategy.&nbsp; <DIV>&nbsp;</DIV><DIV>The "Ex03_ExploringFetchStrategies.docx" in the Fundamentals series of Learning Units has a discussion on this topic.</DIV>]]>
   </description>
   <pubDate>Tue, 26 May 2009 11:03:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1280&amp;PID=4643#4643</guid>
  </item> 
  <item>
   <title>Devforce Queries and IQueryable&lt;T&gt;.Count() : Hi, We are using Devforce 5.1...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1280&amp;PID=4639#4639</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=77" rel="nofollow">jozza</a><br /><strong>Subject:</strong> 1280<br /><strong>Posted:</strong> 25-May-2009 at 6:14pm<br /><br /><P>Hi,</P><P>We are using Devforce 5.1 and I've come across an issue where IQueryable&lt;T&gt;.Count() seems to return only the count of entities that are actually in the database and does not include the ones that have been newly created and are still&nbsp;in the cache.</P><P>As an example I have used Northwind and the Product table.</P><FONT size=2><DIV><FONT color=#2b91af size=2><FONT color=#2b91af size=2><P>Facade</FONT></FONT><FONT size=2> facade = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Facade</FONT></FONT><FONT size=2>();</P></FONT></DIV><DIV>DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>DomainModelEntityManager</FONT></FONT><FONT size=2> mgr = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>DomainModelEntityManager</FONT></FONT><FONT size=2>();</FONT></DIV><DIV><FONT size=2>&nbsp;</DIV><DIV></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> count = facade.GetProducts(mgr).Count&lt;DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Product</FONT></FONT><FONT size=2>&gt;();&nbsp; &lt;=== This returns 77</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Product</FONT></FONT><FONT size=2> p = DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Product</FONT></FONT><FONT size=2>.Create(mgr, 9000, </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Test"</FONT></FONT><FONT size=2>); &lt;=== We create a new product</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>count = facade.GetProducts(mgr).Count&lt;DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Product</FONT></FONT><FONT size=2>&gt;(); &lt;=== This still returns 77</FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#2b91af size=2><FONT color=#2b91af size=2>List</FONT></FONT><FONT size=2>&lt;DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Product</FONT></FONT><FONT size=2>&gt; l = facade.GetProducts(mgr).ToList&lt;DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Product</FONT></FONT><FONT size=2>&gt;(); &lt;== We convert it to List</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>count = l.Count&lt;DomainModel.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Product</FONT></FONT><FONT size=2>&gt;(); &lt;==== Now the count has 78</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>The only way I have been able to get the correct count of items in my entity set is to convert the IQueryable results to a List, and then get a count.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Is this a bug? or something done by design? If so, what was the rationale behind it?</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Cheers</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Jacob Jozwiak</DIV><DIV>&nbsp;</DIV><DIV></FONT>&nbsp;</DIV>]]>
   </description>
   <pubDate>Mon, 25 May 2009 18:14:07 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1280&amp;PID=4639#4639</guid>
  </item> 
 </channel>
</rss>