<?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>Codelab Blog &#187; Lambda</title>
	<atom:link href="http://blog.codelab.co.nz/tag/lambda/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codelab.co.nz</link>
	<description>Technical Articles and News from Codelab Ltd</description>
	<lastBuildDate>Tue, 17 Jan 2012 13:10:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OrderBy making null records come last Entity Framework and Linq</title>
		<link>http://blog.codelab.co.nz/2011/07/28/orderby-making-null-records-come-last-entity-framework-and-linq/</link>
		<comments>http://blog.codelab.co.nz/2011/07/28/orderby-making-null-records-come-last-entity-framework-and-linq/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 11:45:02 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Linq]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=352</guid>
		<description><![CDATA[Ever want to sort your result set but make sure the records with a null sorting column appear last? See the example below var results = (from x in EntityObjectContext.MyTable &#160; &#160; &#160; &#160; &#160; &#160; &#160; select x &#160; &#160; &#160; &#160; &#160; &#160; &#160; into grp &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Ever want to sort your result set but make sure the records with a null sorting column appear last?<br />
See the example below</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var results = (from x in EntityObjectContext.MyTable<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select x<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; into grp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select new<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mydata = grp,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myid = grp.id,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mysortingentity = grp.mysortingentity<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;).OrderBy(x =&gt; sortingcolumn == null).ThenBy(x =&gt; x.mysortingentity.Name).ThenBy(x =&gt; x.myid);</div></div>
<p>Watch this space, this can easily be transformed into a Extension Method.  Check out this link <a href="http://tahirhassan.blogspot.com/2010/06/linq-to-sql-order-by-nulls-last.html">http://tahirhassan.blogspot.com/2010/06/linq-to-sql-order-by-nulls-last.html</a>, this Extension method works for LinqToSQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2011/07/28/orderby-making-null-records-come-last-entity-framework-and-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Nested Functions in C#</title>
		<link>http://blog.codelab.co.nz/2008/09/07/using-nested-functions-in-c/</link>
		<comments>http://blog.codelab.co.nz/2008/09/07/using-nested-functions-in-c/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 10:40:57 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Lambda]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=25</guid>
		<description><![CDATA[Scenario We currently have a templating API system where this allows developers to use a combination of C# and HTML markup to customized the display of the client&#8217;s websites. In this case, I needed a way to quickly perform some calculations and formatting without having to declare the function at design-time. My problem was I [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } --></p>
<p style="margin-bottom: 0cm;"><strong>Scenario<br />
</strong></p>
<p style="margin-bottom: 0cm;">We currently have a templating API system where this allows developers to use a combination of C# and HTML markup to customized the display of the client&#8217;s websites.    In this case, I needed a way to quickly perform some calculations and formatting without having to declare the function at design-time.   My problem was I was to pass in a Boolean, a integer and a string that performed specific logic to produce a outcome (a string).</p>
<p style="margin-bottom: 0cm;"><strong>Solution</strong></p>
<p style="margin-bottom: 0cm;">I was able to use a Func delegate specifying the parameter types and the return type.   With a help of Lambda expressions I was able to capture the input of the three variables and return the result.</p>
<blockquote>
<p style="margin-bottom: 0cm;">Func&lt;bool, int, String, String&gt; nestedFunction = (b, i, s) =&gt; { //Do something return s; };<br />
String foo = nestedFunction(true,1,&#8221;format string&#8221;);</p></blockquote>
<p style="margin-bottom: 0cm;">
<p style="margin-bottom: 0cm;"><strong>References</strong></p>
<p style="margin-bottom: 0cm;"><a href="http://www.codeguru.com/csharp/csharp/cs_misc/designtechniques/article.php/c12749/">http://www.codeguru.com/csharp/csharp/cs_misc/designtechniques/article.php/c12749/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2008/09/07/using-nested-functions-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

