<?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>Powertips &#187; Linq To Object</title>
	<atom:link href="http://scripting.chaindb.com/category/dotnet/linq-dotnet/linq-to-object/feed/" rel="self" type="application/rss+xml" />
	<link>http://scripting.chaindb.com</link>
	<description>Programmer tips</description>
	<lastBuildDate>Tue, 15 May 2012 23:56:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Linq Exception(NullReferenceException): Object reference not set to an instance of an object</title>
		<link>http://scripting.chaindb.com/2010/09/24/linq-exceptionnullreferenceexception-object-reference-not-set-to-an-instance-of-an-object/</link>
		<comments>http://scripting.chaindb.com/2010/09/24/linq-exceptionnullreferenceexception-object-reference-not-set-to-an-instance-of-an-object/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 05:35:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq Exceptions]]></category>
		<category><![CDATA[Linq To Object]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[NullReferece]]></category>
		<category><![CDATA[NullReferenceException]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=868</guid>
		<description><![CDATA[With NullReferenceException: &#160;Dim obj As DemographicProperties = Me &#160; &#160; &#160; &#160; &#160; Dim m As IEnumerable&#40;Of DemographicProperty&#41; = From c In obj _ &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Where &#40;c.MapClass.MapClassID = MapClassID&#41; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>With NullReferenceException:</strong></p>
<div class="geshi no vbnet">
<ol>
<li class="li1">
<div class="de1">&nbsp;<span class="kw6">Dim</span> obj <span class="kw2">As</span> DemographicProperties <span class="sy0">=</span> <span class="kw2">Me</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw6">Dim</span> m <span class="kw2">As</span> IEnumerable<span class="br0">&#40;</span>Of DemographicProperty<span class="br0">&#41;</span> <span class="sy0">=</span> From c In obj _</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Where <span class="br0">&#40;</span>c.<span class="me1">MapClass</span>.<span class="me1">MapClassID</span> <span class="sy0">=</span> MapClassID<span class="br0">&#41;</span> &nbsp;_</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Order By c.<span class="me1">Name</span> Ascending _</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw6">Select</span> c</div>
</li>
</ol>
</div>
<p>If you are getting NullReferenceException, it means the MapClassID is null(nothing in vb.net)</p>
<p><strong>Solve:</strong></p>
<div class="geshi no vbnet">
<ol>
<li class="li1">
<div class="de1">&nbsp;<span class="kw6">Dim</span> obj <span class="kw2">As</span> DemographicProperties <span class="sy0">=</span> <span class="kw2">Me</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw6">Dim</span> m <span class="kw2">As</span> IEnumerable<span class="br0">&#40;</span>Of DemographicProperty<span class="br0">&#41;</span> <span class="sy0">=</span> From c In obj _</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Where <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="kw5">Not</span> c.<span class="me1">MapClass</span> <span class="kw2">Is</span> <span class="kw2">Nothing</span><span class="br0">&#41;</span> <span class="kw2">AndAlso</span> <span class="br0">&#40;</span>c.<span class="me1">MapClass</span>.<span class="me1">MapClassID</span> <span class="sy0">=</span> MapClassID<span class="br0">&#41;</span><span class="br0">&#41;</span> _</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Order By c.<span class="me1">Name</span> Ascending _</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw6">Select</span> c</div>
</li>
</ol>
</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7360303176440694";
/* scripting_Banner (468 x 60) */
google_ad_slot = "0537236933";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2010/09/24/linq-exceptionnullreferenceexception-object-reference-not-set-to-an-instance-of-an-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

