<?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>Beckh@m&#039;s Blog &#187; LINQ</title>
	<atom:link href="http://beckh0m.wordpress.com/category/linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://beckh0m.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 04 Apr 2012 23:47:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='beckh0m.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Beckh@m&#039;s Blog &#187; LINQ</title>
		<link>http://beckh0m.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://beckh0m.wordpress.com/osd.xml" title="Beckh@m&#039;s Blog" />
	<atom:link rel='hub' href='http://beckh0m.wordpress.com/?pushpress=hub'/>
		<item>
		<title>PLINQO: Professional LINQ to Objects</title>
		<link>http://beckh0m.wordpress.com/2008/07/07/plinqo-professional-linq-to-objects/</link>
		<comments>http://beckh0m.wordpress.com/2008/07/07/plinqo-professional-linq-to-objects/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 10:07:36 +0000</pubDate>
		<dc:creator>beckh0m</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[LINQ PLINQ Code Smith]]></category>

		<guid isPermaLink="false">http://beckh0m.wordpress.com/?p=24</guid>
		<description><![CDATA[PLINQO, which stands for Professional LINQ to Objects, is a collection of Code Smith templates that are meant to replace and extend the LINQ to SQL designers that are included with Visual Studio 2008. For more information about PLINQO Check out Paul welter&#8217;s post here. Beckham<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=beckh0m.wordpress.com&#038;blog=11025696&#038;post=24&#038;subd=beckh0m&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span style="font-size:12pt;font-family:&quot;"><font size="4" face="Times New Roman"><u><b>PLINQO</b></u>, </font>which stands for Professional LINQ to Objects, is a<br />
collection of <a href="http://www.codesmithtools.com/">Code Smith</a> templates that are meant to replace and extend the<br />
LINQ to SQL designers that are included with Visual Studio 2008.</span></p>
<h1><font size="2"><span style="font-size:12pt;font-family:&quot;">For more information about PLINQO<br />
Check out <a href="http://community.codesmithtools.com/blogs/pwelter/">Paul welter&#8217;s</a> post <a href="http://community.codesmithtools.com/blogs/pwelter/archive/2007/08/08/plinqo.aspx">here</a>.</span></font><span style="font-size:24pt;font-family:&quot;color:windowtext;"></span></h1>
<p>Beckham</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/beckh0m.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/beckh0m.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beckh0m.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beckh0m.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beckh0m.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beckh0m.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beckh0m.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beckh0m.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beckh0m.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beckh0m.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beckh0m.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beckh0m.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beckh0m.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beckh0m.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beckh0m.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beckh0m.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=beckh0m.wordpress.com&#038;blog=11025696&#038;post=24&#038;subd=beckh0m&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://beckh0m.wordpress.com/2008/07/07/plinqo-professional-linq-to-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1cb642e3bf0857c937c48cab52bcd3d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">beckh0m</media:title>
		</media:content>
	</item>
		<item>
		<title>Sorting a Grid View That&#8217;s bounded to IEnumerable</title>
		<link>http://beckh0m.wordpress.com/2008/03/22/sorting-a-grid-view-thats-bounded-to-ienumerable/</link>
		<comments>http://beckh0m.wordpress.com/2008/03/22/sorting-a-grid-view-thats-bounded-to-ienumerable/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 09:39:37 +0000</pubDate>
		<dc:creator>beckh0m</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Grid View IEnumerable Sorting a Grid View]]></category>

		<guid isPermaLink="false">http://beckh0m.wordpress.com/?p=15</guid>
		<description><![CDATA[Have you ever had a grid view that&#8217;s bounded to an IEnumerable collection? Yes. Very well have you ever wanted to enable sorting to this grid view? Yeah, what&#8217;s the big deal? Okay, here is the deal:- Grid view enable automatic sorting that allows you to sort you data in the grid view without writing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=beckh0m.wordpress.com&#038;blog=11025696&#038;post=15&#038;subd=beckh0m&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have you ever had a grid view that&#8217;s bounded to an IEnumerable collection? Yes.<br />
Very well have you ever wanted to enable sorting to this grid view? Yeah, what&#8217;s the big deal?</p>
<p><strong>Okay, here is the deal:-<br />
</strong><br />
Grid view enable automatic sorting that allows you to sort you data in the grid view without writing any code but sadly this automatic sorting is enabled only for Grid View that&#8217;s bounded to a DataSourceControl (i.e. SqlDataSource, ObjectDataSource).<br />
You can&#8217;t do that with grid view that&#8217;s bounded to an IEnumerable collection, why?<br />
Because actually the grid view uses the DataSourceControl to sort the data for it.</p>
<p>So how can I sort my gridview that&#8217;s bounded to a IEnumerable collection? You can reconstruct your collection as a table and then pass that table to a data view and sort these data using that data view sorting and then bind your grid view to the data view like that :-&gt;</p>
<p><img src="http://img213.imageshack.us/img213/4987/customerlistandclassvp6.jpg" alt="" /></p>
<p>This is the defenition of our customer class that will be used to fill our collection.<br />
Notic: The serializable attribute only so we can save our list of cutomers to the ViewState.</p>
<p><img src="http://img329.imageshack.us/img329/3405/sortexpressionanddirectaj3.png" alt="" /></p>
<p>We will need to keep track of our current sort expression and direction so we can use it later in resorting the list.</p>
<p><img src="http://img170.imageshack.us/img170/5742/pageloaduz4.jpg" alt="" /></p>
<p>Her we fill our list of customers with some dummy data.</p>
<p><img src="http://img329.imageshack.us/img329/5357/sortdirectionmethodhi3.jpg" alt="" /></p>
<p>Change the sort direction from Ascending to Descending and vice versa.</p>
<p><img src="http://img172.imageshack.us/img172/7820/sortingeventhandlerwk1.jpg" alt="" /></p>
<p>Look at our Sorting event handler see how much code we wrote to get this done. Is this the only way to do that ?? Noooo, we can do that very easily using LINQ without creating a table or a data view.</p>
<p><span class="style1"><strong><span style="font-size:medium;">LINQ To The Rescue:-</span></strong></span><br />
See all that code we wrote to create a table and fill the table with data and then creating the creating the data view, well we don&#8217;t need all of that.<br />
We will use the Order by extension method to sort our IEnumerable collection.<br />
ex: -</p>
<p><img src="http://img179.imageshack.us/img179/6472/sortnglistnk0.jpg" alt="" /></p>
<p>Well that&#8217;s great and everything but dude you hard coded the sort expression &#8220;customer.Id&#8221; what will I do if the user clicks on the Name column? Well you can continue hard coding and write an order by statement for each column you have and select the appropriate statement using switch case based on the user&#8217;s selections.<br />
Dude that&#8217;s horrible I don&#8217;t like hard coding, Is there anyway else like passing the property name as a variable? Well, No you can&#8217;t pass the property name as a variable but yes there is another way,  You can use reflection to get the property name dynamically <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img src="http://img510.imageshack.us/img510/6309/sortnglistusingreflectiwn8.jpg" alt="" /></p>
<p>Here is our Sorting event handler after using Orderby and reflection :-</p>
<p><img src="http://img329.imageshack.us/img329/9833/sortinghandlerafterreflja3.jpg" alt="" /></p>
<p><strong>Beckham</strong></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/beckh0m.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/beckh0m.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/beckh0m.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/beckh0m.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/beckh0m.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/beckh0m.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/beckh0m.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/beckh0m.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/beckh0m.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/beckh0m.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/beckh0m.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/beckh0m.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/beckh0m.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/beckh0m.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/beckh0m.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/beckh0m.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=beckh0m.wordpress.com&#038;blog=11025696&#038;post=15&#038;subd=beckh0m&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://beckh0m.wordpress.com/2008/03/22/sorting-a-grid-view-thats-bounded-to-ienumerable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f1cb642e3bf0857c937c48cab52bcd3d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">beckh0m</media:title>
		</media:content>

		<media:content url="http://img213.imageshack.us/img213/4987/customerlistandclassvp6.jpg" medium="image" />

		<media:content url="http://img329.imageshack.us/img329/3405/sortexpressionanddirectaj3.png" medium="image" />

		<media:content url="http://img170.imageshack.us/img170/5742/pageloaduz4.jpg" medium="image" />

		<media:content url="http://img329.imageshack.us/img329/5357/sortdirectionmethodhi3.jpg" medium="image" />

		<media:content url="http://img172.imageshack.us/img172/7820/sortingeventhandlerwk1.jpg" medium="image" />

		<media:content url="http://img179.imageshack.us/img179/6472/sortnglistnk0.jpg" medium="image" />

		<media:content url="http://img510.imageshack.us/img510/6309/sortnglistusingreflectiwn8.jpg" medium="image" />

		<media:content url="http://img329.imageshack.us/img329/9833/sortinghandlerafterreflja3.jpg" medium="image" />
	</item>
	</channel>
</rss>
