<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Montelof&#039;s Blog &#187; row_count</title>
	<atom:link href="http://montelof.wordpress.com/tag/row_count/feed/" rel="self" type="application/rss+xml" />
	<link>http://montelof.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 06 Oct 2011 02:00:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='montelof.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/032e562b7f2d72d4c03951dc283d2d27?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Montelof&#039;s Blog &#187; row_count</title>
		<link>http://montelof.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://montelof.wordpress.com/osd.xml" title="Montelof&#039;s Blog" />
	<atom:link rel='hub' href='http://montelof.wordpress.com/?pushpress=hub'/>
		<item>
		<title>GroupBy two fields,correlate another entity, Count matching rows, show row_number using Lambda</title>
		<link>http://montelof.wordpress.com/2011/03/16/groupby-two-fieldscorrelate-another-entity-cont-matching-rows-show-row_number-using-lambda/</link>
		<comments>http://montelof.wordpress.com/2011/03/16/groupby-two-fieldscorrelate-another-entity-cont-matching-rows-show-row_number-using-lambda/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 15:34:47 +0000</pubDate>
		<dc:creator>montelof</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[distinct]]></category>
		<category><![CDATA[groupby]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[row_count]]></category>

		<guid isPermaLink="false">https://montelof.wordpress.com/2011/03/16/groupby-two-fieldscorrelate-another-entity-cont-matching-rows-show-row_number-using-lambda/</guid>
		<description><![CDATA[I want to count the Tickets owned by every employee, having two Entities,related by Login_ID, so I have first to get the distinct values from the first list, then count the matching rows of the second list, I also want to assign an image url to each employee so I need a row_count like variable, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=montelof.wordpress.com&#038;blog=7755910&#038;post=173&#038;subd=montelof&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I want to count the Tickets owned by every employee, having two Entities,related by Login_ID, so I have first to get the distinct values from the first list, then count the matching rows of the second list, I also want to assign an image url to each employee so I need a row_count like variable, also the related tickets to each employee must match the Team assigned to the employee so the correlated query must consider two fields:</p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;color:blue;font-size:10pt;">int</span><span style="font-family:&quot;font-size:10pt;"> index = 0;
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;color:blue;font-size:10pt;">var</span><span style="font-family:&quot;font-size:10pt;"> workload = grouplist.GroupBy(j =&gt; <span style="color:blue;">new</span> { j.LOGIN_ID, j.FULL_NAME,j.TEAM_NAME})
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>.Where(k =&gt; k.Key.TEAM_NAME == membergroup)
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>.Select(i =&gt; <span style="color:blue;">new
</p>
<p>     </span></span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>CoreID = i.Key.LOGIN_ID,
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>TicketCount = tickets
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>.Where(k =&gt; k.Assignee_Login_ID == i.Key.LOGIN_ID&#160;&#160; &amp;&amp;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; k.Assigned_Group==i.Key.TEAM_NAME)
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>.Count(),
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>Assignee = i.Key.FULL_NAME,
</p>
<p>   </span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>url = <span style="color:#a31515;">@&quot;~\images\man_&quot;</span> + (1 + (index++) % 5) + <span style="color:#a31515;">&quot;.png&quot;
</p>
<p>     </span></span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}).ToList();<span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span></span></span></p>
<p style="line-height:normal;margin-bottom:0;" class="MsoNormal"><span style="font-family:&quot;font-size:10pt;"><span>I choose to use Lambda instead of Linq because of simplicity, Ill post another example using left outer join using Linq in the next one.&#160;&#160;&#160; </span>
</p>
<p>   </span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/montelof.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/montelof.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/montelof.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/montelof.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/montelof.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/montelof.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/montelof.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/montelof.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/montelof.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/montelof.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/montelof.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/montelof.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/montelof.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/montelof.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=montelof.wordpress.com&#038;blog=7755910&#038;post=173&#038;subd=montelof&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://montelof.wordpress.com/2011/03/16/groupby-two-fieldscorrelate-another-entity-cont-matching-rows-show-row_number-using-lambda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3fa60af85bba005898f62ed1aa527ae3?s=96&#38;d=http%3A%2F%2Fs0.wp.com%2Fi%2Fmu.gif&#38;r=G" medium="image">
			<media:title type="html">montelof</media:title>
		</media:content>
	</item>
	</channel>
</rss>
