<?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; Linq</title>
	<atom:link href="http://blog.codelab.co.nz/tag/linq/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>The custom tool ‘MSLinqToSQLGenerator’ failed. Unspecified error</title>
		<link>http://blog.codelab.co.nz/2010/01/18/the-custom-tool-%e2%80%98mslinqtosqlgenerator%e2%80%99-failed-unspecified-error/</link>
		<comments>http://blog.codelab.co.nz/2010/01/18/the-custom-tool-%e2%80%98mslinqtosqlgenerator%e2%80%99-failed-unspecified-error/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 08:29:15 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Linq]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=172</guid>
		<description><![CDATA[I kept getting this error &#8220;The custom tool &#8216;MSLinqToSQLGenerator&#8217; failed.  Unspecified error.   For me, this was caused when I was using partial classes and had several using statements at the top of the file: using System.Data.Linq; using System.Data.Linq.Mapping; using System.Data; using System.Collections.Generic; using System.Reflection; using System.Linq; using System.Linq.Expressions; using System.ComponentModel; using System; {namespace} {code} To [...]]]></description>
			<content:encoded><![CDATA[<p>I kept getting this error &#8220;The custom tool &#8216;MSLinqToSQLGenerator&#8217; failed.  Unspecified error.   For me, this was caused when I was using partial classes and had several using statements at the top of the file:</p>
<p>using System.Data.Linq;<br />
using System.Data.Linq.Mapping;<br />
using System.Data;<br />
using System.Collections.Generic;<br />
using System.Reflection;<br />
using System.Linq;<br />
using System.Linq.Expressions;<br />
using System.ComponentModel;<br />
using System;</p>
<p>{namespace}</p>
<p>{code}</p>
<p>To get around this, I removed the using namespaces and ran the custom build tool, then readded the using statements which resolved my issue.   This issue apparently is in SP1 VS2008!</p>
<p><em><strong>References:</strong></em></p>
<p><a href="http://blog.unidev.com/index.php/2008/09/02/the-custom-tool-mslinqtosqlgenerator-failed-unspecified-error/">http://blog.unidev.com/index.php/2008/09/02/the-custom-tool-mslinqtosqlgenerator-failed-unspecified-error/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2010/01/18/the-custom-tool-%e2%80%98mslinqtosqlgenerator%e2%80%99-failed-unspecified-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Serializing a Data Class (LINQ2SQL) for WCF</title>
		<link>http://blog.codelab.co.nz/2008/04/12/serializing-a-data-class-linq2sql-for-wcf/</link>
		<comments>http://blog.codelab.co.nz/2008/04/12/serializing-a-data-class-linq2sql-for-wcf/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 08:47:59 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=10</guid>
		<description><![CDATA[Problem I created a class that implements a service contract interface so that I can return an array of data from a WCF service back to the client application. The exposed method in the class return’s an array of Data Classes (an array of records from a database table) generated by the MSLINQ2SQL generator. When [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong></p>
<p>I created a class that implements a service  contract interface so that I can return an array of data from a WCF service back  to the client application.</p>
<p>The exposed method in the class return’s an  array of Data Classes (an array of records from a database table) generated by  the MSLINQ2SQL generator.</p>
<p>When generating the client code from the WCF  service, an exception was raised stating<br />
That the class could not be  serialized.</p>
<blockquote><p><em><span style="font-size: 85%;">S</span></em><span style="font-size: 85%;">ervice cannot be started.  System.Runtime.Serialization.InvalidDataContractException: Type  &#8216;TDC_LIB.OM.TMPPlan&#8217; cannot be serialized. Consider marking it with the  DataContractAttribute attribute, and marking all of its members you want  serialized with the DataMemberAttribute attribute.<br />
at  System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String  message, Type type)<br />
at  System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32  id, RuntimeTypeHandle typeHandle, Type type)<br />
at  System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32  id, RuntimeTypeHandle typeHandle, Type type)<br />
at  System.Runtime.Serialization.DataContract.GetDataContractSkipValidation(Int32  id, RuntimeTypeHandle typeHandle, Type type)<br />
at  System.Runtime.Serialization.DataContract.GetDataContract(RuntimeTypeHandle  typeHandle, Type type, SerializationMode mode)<br />
at  System.Runtime.Serialization.DataContract.GetDataContr&#8230;</span><em></em><strong></strong></p></blockquote>
<p><strong>Solution</strong><br />
Make  sure that your data context object has the property <strong>“Serialization  Mode”</strong> set to Unidirectional. This will add DataContract/DataMember  attributes to the associated fields in your data classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2008/04/12/serializing-a-data-class-linq2sql-for-wcf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

