<?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 : Dynamic Group By and Count</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Dynamic Group By and Count</description>
  <pubDate>Wed, 13 May 2026 18:18:40 -700</pubDate>
  <lastBuildDate>Thu, 15 Sep 2011 20:23:42 -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=2960</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>Dynamic Group By and Count :   That looks like it would do...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11677#11677</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=916" rel="nofollow">BringerOD</a><br /><strong>Subject:</strong> 2960<br /><strong>Posted:</strong> 15-Sep-2011 at 8:23pm<br /><br />That looks like it would do it.<div>&nbsp;</div><div>I did not think to add a select field of "Count()".</div><div>&nbsp;</div><div>Thanks</div>]]>
   </description>
   <pubDate>Thu, 15 Sep 2011 20:23:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11677#11677</guid>
  </item> 
  <item>
   <title>Dynamic Group By and Count :  Hi Bryan;Is this the type of...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11676#11676</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> 2960<br /><strong>Posted:</strong> 15-Sep-2011 at 8:16pm<br /><br />Hi Bryan;<div><br></div><div>Is this the type of query that you want to do dynamically?</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div>query.GroupBy(g =&gt; g.CategoryID).Select(s =&gt; new { Name = s.Key, Total = s.Count() });</div><div></pre></td></tr></table></div><div><br></div><div>if so, this is how you would do it,</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>var groupBySelector = new AnonymousProjectionSelector().Combine("CategoryID");</div><div>var selectSelector = new ProjectionSelector("Key", "Name").Combine("Count()", "Total");</div><div><br></div><div>var q0 = query.GroupBy(groupBySelector).Select(selectSelector);</div></div><div></pre></td></tr></table></div><span style="font-size:10px"><br /><br />Edited by DenisK - 15-Sep-2011 at 8:26pm</span>]]>
   </description>
   <pubDate>Thu, 15 Sep 2011 20:16:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11676#11676</guid>
  </item> 
  <item>
   <title>Dynamic Group By and Count : I figured out a way to do it using...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11675#11675</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=916" rel="nofollow">BringerOD</a><br /><strong>Subject:</strong> 2960<br /><strong>Posted:</strong> 15-Sep-2011 at 3:28pm<br /><br /><p ="Ms&#111;normal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;  mso-ascii-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:  &quot;Times New Roman&quot;;mso-bidi-theme-font:minor-bidi;color:#1F497D;mso-themecolor:  dark2">I figured out a way to do it using this<o:p></o:p></span></p><p ="Ms&#111;normal"><a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx</a></p><p ="Ms&#111;normal"><o:p></o:p></p><p ="Ms&#111;normal">It’s a way to do linq queries dynamically.</p><p ="Ms&#111;normal"><o:p></o:p></p><p ="Ms&#111;normal"><span style="font-size:9.5pt;font-family:C&#111;nsolas;color:#2B91AF">var</span><span style="font-size:9.5pt;font-family:C&#111;nsolas"> result = query.GroupBy(“FieldToGroup”,<span style="color:#A31515">"it"</span>).Select(<span style="color:#A31515">"new(Keyas Name, Count() as Total)"</span>);</span></p><p ="Ms&#111;normal"><span style="font-size:9.5pt;font-family:C&#111;nsolas">Bryan</span></p><p ="Ms&#111;normal"><span style="font-size:9.5pt;font-family:C&#111;nsolas"><br></span></p>]]>
   </description>
   <pubDate>Thu, 15 Sep 2011 15:28:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11675#11675</guid>
  </item> 
  <item>
   <title>Dynamic Group By and Count : Does anyone know how to get a...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11672#11672</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=916" rel="nofollow">BringerOD</a><br /><strong>Subject:</strong> 2960<br /><strong>Posted:</strong> 15-Sep-2011 at 9:41am<br /><br /><div>Does anyone know how to get a groupby count from a dynamic query? &nbsp;I can group by a field, I just can't get it's count without pulling all the records down. &nbsp; I just want the group field and how many there are.</div><div><br></div><div>This works, but only returns the key.</div><div>var selector = new AnonymousProjectionSelector().Combine("Key");</div><div><br></div><div><br></div><div>This does not. &nbsp;I was only guessing anyway.</div><div>var selector = new AnonymousProjectionSelector().Combine("Key").Combine("Key.Count","Count");</div><div><br></div><div><br></div><div>Code</div><div><br></div><div><div>&nbsp; &nbsp; &nbsp; public void ReadDistinctValuesAndCounts(object sender, QueryGroupsEventArgs e)</div><div>&nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var query = BuildWhereClause(e.CollectionView, e.GroupPath, _baseQuery);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;query = BuildSortClause(e.CollectionView, query);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var groupByField = e.ChildGroupPropertyName;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var groupBy = new ProjectionSelector(groupByField);</div><div>&nbsp; &nbsp;</div><div><span ="Apple-tab-span" style="white-space:pre">	</span>var selector = new AnonymousProjectionSelector().Combine("Key");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ITypedEntityQuery groupByQuery = query.GroupBy(groupBy).Select(selector);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var result = groupByQuery.Execute();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp;}</div></div>]]>
   </description>
   <pubDate>Thu, 15 Sep 2011 09:41:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2960&amp;PID=11672#11672</guid>
  </item> 
 </channel>
</rss>