<?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" >

<channel>
	<title>Even the wrong words seem to rhyme &#187; geshi</title>
	<atom:link href="http://www.kevinblake.co.uk/tag/geshi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kevinblake.co.uk</link>
	<description>a blog-life by Kevin Blake</description>
	<lastBuildDate>Thu, 13 May 2010 22:27:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Code highlighting, and the magic of LINQ</title>
		<link>http://www.kevinblake.co.uk/code-highlighting-and-the-magic-of-linq/182/</link>
		<comments>http://www.kevinblake.co.uk/code-highlighting-and-the-magic-of-linq/182/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 14:37:19 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[geshi]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=182</guid>
		<description><![CDATA[I&#8217;ve had a small block of code in my drafts folder for quite some time now, just looking for an excuse to publish it.  I&#8217;ve been using LINQ a lot in the past 6 months, and it&#8217;s one of the recent additions to the language that&#8217;s made me think twice before using PHP or Perl [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a small block of code in my drafts folder for quite some time now, just looking for an excuse to publish it.  I&#8217;ve been using <abbr title="Language Integrated Query">LINQ</abbr> a lot in the past 6 months, and it&#8217;s one of the recent additions to the language that&#8217;s made me think twice before using PHP or Perl for my own projects (despite the existence of <a href="http://www.codeplex.com/PHPLinq" target="_blank">PHPLinq</a>).</p>
<blockquote><p>HIM: LINQ&#8217;s like pringles<br />
ME: only makes sense after drugs?<br />
HIM: once you pop you can&#8217;t stop</p></blockquote>
<p>But I didn&#8217;t really want to write a full post on LINQ.  It seemed dull.  It&#8217;d been done before.  It&#8217;s old news.</p>
<p>So I picked up the <a href="http://www.fractalizer.ru/freeware-projects/wordpress-plugins/wp-synhighlight/" target="_blank">WP-SynHighlight</a> extension for WordPress.  Which gives some rather cool code-highlighting through <abbr title="Generic Syntax Highlighter">GeSHi</abbr>.</p>
<p>So here&#8217;s some highlighted stylised C# LINQ demonstrating how simple it is to combine LINQ to SQL with LINQ to XML data sources.<br />
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;">var answers <span class="sy0">=</span> <span class="br0">&#40;</span>from a <span class="kw1">in</span> poll.<span class="me1">Descendants</span><span class="br0">&#40;</span><span class="st0">&quot;AnswerSet&quot;</span><span class="br0">&#41;</span>.<span class="me1">Descendants</span><span class="br0">&#40;</span><span class="st0">&quot;Answer&quot;</span><span class="br0">&#41;</span>
join aCount <span class="kw1">in</span> dbVotes
on a.<span class="me1">Attribute</span><span class="br0">&#40;</span><span class="st0">&quot;id&quot;</span><span class="br0">&#41;</span>.<span class="me1">Value</span>  equals aCount.<span class="me1">AnswerId</span>.<span class="me1">ToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span> into aJoined
from o <span class="kw1">in</span> aJoined.<span class="me1">DefaultIfEmpty</span><span class="br0">&#40;</span><span class="br0">&#41;</span>
select <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> <span class="br0">&#123;</span>
id <span class="sy0">=</span> a.<span class="me1">Attribute</span><span class="br0">&#40;</span><span class="st0">&quot;id&quot;</span><span class="br0">&#41;</span>.<span class="me1">Value</span>,
percentage <span class="sy0">=</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>o <span class="sy0">==</span> <span class="kw1">null</span> <span class="sy0">?</span> 0 <span class="sy0">:</span> o.<span class="me1">VotesCount</span><span class="br0">&#41;</span> <span class="sy0">/</span> dbVotes.<span class="me1">Sum</span><span class="br0">&#40;</span>b <span class="sy0">=&gt;</span> b.<span class="me1">VotesCount</span>.<span class="me1">GetValueOrDefault</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>  <span class="sy0">*</span> 100<span class="br0">&#41;</span>,
count <span class="sy0">=</span> o <span class="sy0">==</span> <span class="kw1">null</span> <span class="sy0">?</span> 0 <span class="sy0">:</span> o.<span class="me1">VotesCount</span>, text <span class="sy0">=</span> a.<span class="me1">Value</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div></p>
<p>Now if only Microsoft would release LINQ to XSD out of preview.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/code-highlighting-and-the-magic-of-linq/182/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
