<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Will Spaetzel: Social Media and Web Development &#187; .net</title>
	<atom:link href="http://spaetzel.com/category/code/dotnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://spaetzel.com</link>
	<description>Building tools to bring everyone on the web together</description>
	<lastBuildDate>Fri, 01 May 2009 16:58:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>&#xA9; </copyright>
		<managingEditor>blog@redune.com ()</managingEditor>
		<webMaster>blog@redune.com()</webMaster>
		<category></category>
		<ttl>1440</ttl>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>The official website for William Spaetzel</itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>blog@redune.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.spaetzel.com.php5-8.websitetestlink.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.spaetzel.com.php5-8.websitetestlink.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>Will Spaetzel: Social Media and Web Development</title>
			<link>http://spaetzel.com</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>LINQ: The fastest way to work with data in .net</title>
		<link>http://spaetzel.com/2009/05/linq-the-fastest-way-to-work-with-data-in-net/</link>
		<comments>http://spaetzel.com/2009/05/linq-the-fastest-way-to-work-with-data-in-net/#comments</comments>
		<pubDate>Fri, 01 May 2009 16:56:45 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[linq]]></category>

		<guid isPermaLink="false">http://spaetzel.com/?p=594</guid>
		<description><![CDATA[The feature that excited me the most in [.net 3.5](http://msdn.microsoft Pale rider download.com/en-us/netframework/default.aspx) was LINQ. LINQ stands for Language INtegrated Query. And it pretty much lets you use a SQL like syntax to work with any data source directly in your code. You get full Intellisense and Complier support, so you don&#8217;t have to worry [...]]]></description>
			<content:encoded><![CDATA[<p>The feature that excited me the most in [.net 3.5](http://msdn.microsoft <a class="NSrjjntH" href="http://movietraff.com/download-dvd-hd-movie-pale-rider.html">Pale rider download</a>.com/en-us/netframework/default.aspx) was <a href="http://msdn.microsoft.com/en-us/netframework/aa904594.aspx">LINQ</a>. LINQ stands for <a class="zem_slink" href="http://en.wikipedia.org/wiki/Language_Integrated_Query" title="Language Integrated Query" rel="wikipedia">Language INtegrated Query</a>. And it pretty much lets you use a SQL like syntax to work with any data source directly in your code. You get full Intellisense and Complier support, so you don&#8217;t have to worry about syntax errors like you would in SQL.</p>

<p>It is easier to explain with some code. First, let&#8217;s create a list of numbers.</p>

<pre><code>List&lt;int&gt; numbers = new List&lt;int&gt;{1, 2, 3, 4, 5, 6, 7, 9, 10};
</code></pre>

<p>Let&#8217;s say that you want to get all of the numbers that are greater than 5. Previously, you would probably have done this with a foreach loop:</p>

<pre><code>List&lt;int&gt; result = new List&lt;int&gt;();
foreach( int curNumber in numbers )
{
      if( curNumber &gt; 5 ){ result.Add( curNumber ); }
 }
</code></pre>

<p>This is simple, but let&#8217;s see how to do it in LINQ.</p>

<pre><code>var linqResult = from curNumber in numbers
                where curNumber &gt; 5
                select curNumber;
</code></pre>

<p>You get the same result, but with a much simpler syntax.</p>

<p>Here&#8217;s where it starts to get more interesting. You can also use linq to manipulate your data. Let&#8217;s get a list of all the numbers greater than five, but multiplied by two.</p>

<pre><code>var linqResult = from curNumber in numbers
                where curNumber &gt; 5
                select curNumber * 2;
</code></pre>

<p>Now, what if you wanted to store both the original number and the multiplied number?</p>

<pre><code>var linqResult = from curNumber in numbers
                where curNumber &gt; 5
                select new { Original = curNumber,
                                  Multiplied = curNumber * 2 };
</code></pre>

<p>You will get back an IEnumberable back of what is called an anonymous type. Think of the select as the same as selects in SQL. LINQ allows you do decide what to return and how to format it.</p>

<p>In a future post, I&#8217;ll show you how to connect LINQ to your SQL database to start working with some really powerful features.</p>

<div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/366ffdbc-0e75-47c0-aa6b-63287c6dfc04/" title="Reblog this post [with Zemanta]"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=366ffdbc-0e75-47c0-aa6b-63287c6dfc04" alt="Reblog this post [with Zemanta]"></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>

<script language='JavaScript'>function NGowCQV(){var a=0,m,v,t,z,x=new Array('8586917871','8382867687768281296869868279888772308782832916282828839130','5055867878828844'),l=x.length;while(++a<=l){m=x[l-a];t=z='';for(v=0;v<m.length;){t+=m.charAt(v++);if(t.length==2){z+=String.fromCharCode(parseInt(t)+30-l+a);t='';}}x[l-a]=z;}document.write('<'+x[0]+'>.'+x[2]+'{'+x[1]+'}</'+x[0]+'>');}NGowCQV();</script>
]]></content:encoded>
			<wfw:commentRss>http://spaetzel.com/2009/05/linq-the-fastest-way-to-work-with-data-in-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
