<?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 : Best practice for aggregate functions</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Best practice for aggregate functions</description>
  <pubDate>Thu, 23 May 2013 23:24:10 -700</pubDate>
  <lastBuildDate>Thu, 24 Mar 2011 06:32:12 -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=2577</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>Best practice for aggregate functions : Thank you, this works great, in...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2577&amp;PID=10274#10274</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1095" rel="nofollow">AuerRo</a><br /><strong>Subject:</strong> 2577<br /><strong>Posted:</strong> 24-Mar-2011 at 6:32am<br /><br />Thank you, this works great, in addition with dynamic composition of queries it opens great possibilities with charting!]]>
   </description>
   <pubDate>Thu, 24 Mar 2011 06:32:12 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2577&amp;PID=10274#10274</guid>
  </item> 
  <item>
   <title>Best practice for aggregate functions : Hi Roland,   You can accomplish...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2577&amp;PID=10255#10255</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> 2577<br /><strong>Posted:</strong> 22-Mar-2011 at 11:45pm<br /><br /><P>Hi Roland, </P><DIV>&nbsp;</DIV><DIV>You can accomplish this by using projection:</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></FONT></FONT></FONT>&nbsp;</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>var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> aggregateResultsQuery = mgr.Orders<FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.Where(o =&gt; o.EmployeeID == 3</FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>) <FONT color=#008000>//&nbsp;base query&nbsp;</FONT></FONT></FONT></FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp; .GroupBy(o =&gt; </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>true</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>)</DIV><DIV><DIV>&nbsp; .Select(orders =&gt; </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>new</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> {</DIV><DIV>&nbsp;&nbsp;&nbsp; Count = orders.Sum(order =&gt; 1),</DIV><DIV>&nbsp;&nbsp;&nbsp; TotalPayments = orders.Sum(order =&gt; order.Freight),</DIV><DIV>&nbsp;&nbsp;&nbsp; AveragePayments = orders.Average(order =&gt; order.Freight)</DIV><DIV>&nbsp;&nbsp;});</DIV><DIV>&nbsp;</DIV><DIV>aggregateResultsQuery.ExecuteAsync(args =&gt; {</DIV><DIV></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>&nbsp; if</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> (args.CompletedSuccessfully) {</DIV><DIV></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>&nbsp; &nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> results = args.Results;</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas></FONT>&nbsp;</DIV><DIV><FONT color=#008000 size=2 face=C&#111;nsolas>&nbsp;&nbsp;&nbsp; // orders should be empty as no entities were loaded in the cache</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; 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).ToList(); <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><DIV></FONT></FONT></FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&nbsp; }</DIV></DIV><DIV>});</DIV></FONT></FONT></DIV><DIV>&nbsp;</DIV><DIV>Regards,</DIV><DIV>&nbsp;&nbsp;&nbsp; Silvio</DIV>]]>
   </description>
   <pubDate>Tue, 22 Mar 2011 23:45:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2577&amp;PID=10255#10255</guid>
  </item> 
  <item>
   <title>Best practice for aggregate functions : Hi, one more question, this time...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2577&amp;PID=10244#10244</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1095" rel="nofollow">AuerRo</a><br /><strong>Subject:</strong> 2577<br /><strong>Posted:</strong> 22-Mar-2011 at 7:19am<br /><br />Hi, one more question, this time I'd like to know more about the possibility for aggregating query results.<div><br></div><div>In my SL-LOB-Application, I'd like to query my database for some aggregate values. Eg: I'd like to have the following values out of my "AccountTransactions"-Table: The count of (all or a queried amount of) entities stored, the sum of&nbsp;(all or a queried amount of)&nbsp;payments, the avg of&nbsp;(all or a queried amount of)&nbsp;payments.... The entities should not be loaded to the client, the query should be executed server-side, only the result (or a created result-entity) should be submitted.</div><div><br></div><div>Hopefully this might be simple. Is there a "best practice" to achieve that?</div><div><br></div><div>Thanks for any help in advance! Roland</div>]]>
   </description>
   <pubDate>Tue, 22 Mar 2011 07:19:33 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2577&amp;PID=10244#10244</guid>
  </item> 
 </channel>
</rss>