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

<channel>
	<title>J-dee.com &#187; LINQ</title>
	<atom:link href="http://www.j-dee.com/category/linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.j-dee.com</link>
	<description>Liverpool ASP.NET Developer - C#, jQuery, Js, Rails, SQL, Agile, OOP, Cool Web Tech</description>
	<lastBuildDate>Sat, 05 Dec 2009 10:29:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Super Lambda Bananas</title>
		<link>http://www.j-dee.com/2008/06/29/super-lambda-bananas/</link>
		<comments>http://www.j-dee.com/2008/06/29/super-lambda-bananas/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 08:30:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.j-dee.com/2008/06/29/super-lambda-bananas/</guid>
		<description><![CDATA[ I&#8217;m a big generic collection user and I can&#8217;t express how much the C# 3 Linq expressions have improved my coding experience, especially in the form of lambda syntax. I used to spend a lot of time trying to bend predicates to my will in order to pull the good stuff out of my [...]]]></description>
			<content:encoded><![CDATA[<p><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://www.j-dee.com/wp-content/uploads/2008/06/302279198-06564a7141-m1.jpg" border="0" alt="302279198_06564a7141_m" width="106" height="80" align="left" /> I&#8217;m a big generic collection user and I can&#8217;t express how much the C# 3 Linq expressions have improved my coding experience, especially in the form of lambda syntax. I used to spend a lot of time trying to bend predicates to my will in order to pull the good stuff out of my collections, and some of the new expressions make this a thing of the past.</p>
<p>Some of the expressions do need a bit of extra thought to understand what is going on though. For example, what is the difference between .Where, .TakeWhile and .SkipWhile? They all return a subset of your collection, but what exactly do you get? Let&#8217;s investigate!</p>
<p>So say we start with this:</p>
<pre class="csharpcode"><span class="kwrd">string</span>[] names = {<span class="str">"dave"</span>, <span class="str">"dee"</span>, <span class="str">"dozy"</span>, <span class="str">"beaky"</span>,
<span class="str">"mick"</span>, <span class="str">"titch"</span>, <span class="str">"darius"</span>};

names.Where(name =&gt; name.StartsWith(<span class="str">"d"</span>));</pre>
<p> .Where will return &#8220;dave&#8221;, &#8220;dee&#8221;, &#8220;dozy&#8221; and &#8220;darius&#8221;, matching everything that starts with &#8216;d&#8217;. TakeWhile and SkipWhile are different though, working on your sequence <strong>only until a specified condition is deemed false</strong>. So&#8230;..</p>
<pre class="csharpcode">names.TakeWhile(name =&gt; name.StartsWith(<span class="str">"d"</span>));</pre>
<p>will return &#8220;dave&#8221;, &#8220;dee&#8221; and &#8220;dozy&#8221;: the search is called off when StartsWith(&#8221;d&#8221;) becomes false. Conversely</p>
<pre class="csharpcode">names.SkipWhile(name =&gt; name.StartsWith(<span class="str">"d"</span>));</pre>
<p> </p>
<p>will get you &#8220;beaky&#8221;, &#8220;mick&#8221;, &#8220;titch&#8221; and &#8220;darius&#8221;, skipping the items in the sequence until StartsWith(&#8221;d&#8221;) becomes false.</p>
<p>Try doing that with predicates!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-dee.com/2008/06/29/super-lambda-bananas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ADO.NET Entity Framework Quickstart Tutorial</title>
		<link>http://www.j-dee.com/2008/06/03/adonet-entity-framework-quickstart-tutorial/</link>
		<comments>http://www.j-dee.com/2008/06/03/adonet-entity-framework-quickstart-tutorial/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 16:29:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EntityFramework]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.j-dee.com/?p=104</guid>
		<description><![CDATA[The ADO.NET Entity framework received another update last week as part of the Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta, so to coincide with this I give you a quick run through to get you started. Being honest, if you have used an OR mapper in the past this will be [...]]]></description>
			<content:encoded><![CDATA[<p>The ADO.NET Entity framework received another update last week as part of the <a href="http://msdn.microsoft.com/en-us/vstudio/products/cc533447.aspx" target="_blank">Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta</a>, so to coincide with this I give you a quick run through to get you started. Being honest, if you have used an OR mapper in the past this will be familiar territory. If not, this new implementation is a good place to start.</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.j-dee.com/wp-content/uploads/2008/06/screenshot11.jpg" border="0" alt="screenshot1" align="left" /> So to begin, create a new ASP.NET website, Add New item, and then choose ADO.NET Entity Data Model. Name it <strong>EntityModel.edmx</strong> and click <strong>Add</strong> to create a new model.</p>
<p>The Entity Data Model Wizard will pop up and give you a chance to configure your new model. For the purposes of this walk through, choose <strong>Generate from database</strong> and click <strong>Next</strong>.</p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.j-dee.com/wp-content/uploads/2008/06/screenshot41.jpg" border="0" alt="screenshot4" align="right" /> Set up your data connection, I won&#8217;t go into this as it&#8217;s simple enough to figure out if you&#8217;ve never done it before. Click the checkbox to save entity connection settings into your web.config and name it <strong>MyEntities.</strong></p>
<p><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" src="http://www.j-dee.com/wp-content/uploads/2008/06/screenshot61.jpg" border="0" alt="screenshot6" width="167" height="221" align="left" />The wizard will then tootle off and retrieve the names of all the tables, views and stored procedures in your database. Choose a table ( I&#8217;ve chosen a table from my DB called &#8216;Log&#8217; ) and name the Model Namespace <strong>MyModel</strong>.</p>
<p>Click <strong>Finish</strong> and the designer for your model will open. As a side note have a look at the Model Browser on the right hand side &#8211; it looks a bit &#8216;rendered&#8217; for want of a better description, as though it&#8217;s drawn via GDI+ compared to the Solution Explorer&#8230;.strange!</p>
<p>Now add a new web page and go into the code behind to start the real work. It&#8217;s just a simple bit of code to CRUD the Log entities in my database.</p>
<p><span style="color: #008000;"><br />
// instantiate a new Log entity<br />
</span>MyModel.<span style="color: #2b91af;">Log </span>log = <span style="color: #0000ff;">new </span>MyModel.<span style="color: #2b91af;">Log</span>();</p>
<p><span style="color: #008000;">// populate it&#8217;s properties<br />
</span>log.Date = <span style="color: #2b91af;">DateTime</span>.Now;<br />
log.Exception = <span style="color: #a31515;">&#8220;Test Exception&#8221;</span>;<br />
log.Level = <span style="color: #a31515;">&#8220;Test Level&#8221;</span>;<br />
log.Logger = <span style="color: #a31515;">&#8220;Test Logger&#8221;</span>;<br />
log.Message = <span style="color: #a31515;">&#8220;Test Message&#8221;</span>;<br />
log.Thread = <span style="color: #a31515;">&#8220;Test Thread&#8221;</span>;</p>
<p><span style="color: #008000;">//instantiate the entity &#8216;context&#8217; &#8211; the object used<br />
//as a &#8216;gateway&#8217; to the DB<br />
</span>MyModel.MyEntities entities = <span style="color: #0000ff;">new </span>MyModel.MyEntities();</p>
<p><span style="color: #008000;">// Save the new log entity to the DB<br />
</span>entities.AddToLog(log);<br />
entities.SaveChanges();</p>
<p><span style="color: #008000;">// Load it back via a little LINQ query<br />
// ( funny how you must use .First instead of .Single )<br />
</span>MyModel.<span style="color: #2b91af;">Log </span>loadedLog = entities.Log .Where(ent =&gt; ent.Level == <span style="color: #a31515;">&#8220;Test Level&#8221;</span>).First();</p>
<p><span style="color: #008000;">// make a change and save it back to the DB<br />
</span>loadedLog.Message = <span style="color: #a31515;">&#8220;Message has changed!&#8221;</span>;<br />
entities.SaveChanges();</p>
<p><span style="color: #008000;">// Finally delete the object from the DB<br />
</span>entities.DeleteObject(loadedLog);<br />
entities.SaveChanges();</p>
<p><strong>Notice how you have to call .SaveChanges() to persist back to the DB. That&#8217;s it! A super fast run through of CRUD with the ADO.NET Entity Framework! Enjoy!</strong> <br/> <br/><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.j-dee.com%2f2008%2f06%2f03%2fadonet-entity-framework-quickstart-tutorial%2f"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.j-dee.com%2f2008%2f06%2f03%2fadonet-entity-framework-quickstart-tutorial%2f" border="0" alt="kick it on DotNetKicks.com" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-dee.com/2008/06/03/adonet-entity-framework-quickstart-tutorial/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>LINQ &#8211; First Impressions</title>
		<link>http://www.j-dee.com/2007/08/20/linq-first-impressions/</link>
		<comments>http://www.j-dee.com/2007/08/20/linq-first-impressions/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 08:42:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Framework]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://www.j-dee.com/2007/08/20/linq-first-impressions/</guid>
		<description><![CDATA[LINQ is pretty good! I&#8217;ve used plenty of ORM tools in the past, and LINQ offers a nice user experience. I spent an hour hooking up Northwind and dragging tables onto the design surface in order to generate some code and the created objects offer some cool features.
The LINQ syntax does feel a bit like [...]]]></description>
			<content:encoded><![CDATA[<p>LINQ is pretty good! I&#8217;ve used plenty of ORM tools in the past, and LINQ offers a nice user experience. I spent an hour hooking up Northwind and dragging tables onto the design surface in order to generate some code and the created objects offer some cool features.<br />
The LINQ syntax does feel a bit like writing inline SQL though, and doesn&#8217;t feel as &#8216;objecty&#8217; as the entities thrown up by Subsonic. The use of the DataContext classes *seem* to offer transactions out the bag, and the hierarchy of methods and properties feel well thought out and usable.</p>
<p>I&#8217;m going to do a little &#8216;Learn LINQ&#8217; series of posts later in the week, so stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j-dee.com/2007/08/20/linq-first-impressions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
