<?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>nPath Ltd. &#187; C#</title>
	<atom:link href="http://www.npathweb.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.npathweb.com</link>
	<description>Web Development Blog</description>
	<lastBuildDate>Tue, 10 Jan 2012 02:22:18 +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>Operator &#8216;==&#8217; incompatible with operand types &#8216;Int32&#8242; and &#8216;Object&#8217;</title>
		<link>http://www.npathweb.com/2009/02/05/operator-incompatible-with-operand-types-int32-and-object/</link>
		<comments>http://www.npathweb.com/2009/02/05/operator-incompatible-with-operand-types-int32-and-object/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:49:52 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Visual Studio 2007]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/blog/?p=5</guid>
		<description><![CDATA[I had this error pop up on me recently. Operator &#8216;==&#8217; incompatible with operand types &#8216;Int32&#8242; and &#8216;Object&#8217; I had an good grasp on why but the stack track would not tell me where! The issue is that a null object was being used in a where clause somewhere. Linq translated the null as &#8220;&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>I had this error pop up on me recently.</p>
<p><span></p>
<h2><em>Operator &#8216;==&#8217; incompatible with operand types &#8216;Int32&#8242; and &#8216;Object&#8217;</em></h2>
<p></span>I had an good grasp on why but the stack track would not tell me where!</p>
<p>The issue is that a null object was being used in a where clause somewhere. Linq translated the null as &#8220;&#8221; and could not be compared the the ID field which is an int.</p>
<p>My solution was to simply check each key and cancel the action if there is a null value.</p>
<p>Since I couldn&#8217;t tell which Linq Data source was crashing I wired up on selecting events for them ALL and put the following code in:</p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="color: #0000ff; font-size: x-small;">foreach</span><span style="font-size: x-small;"> (</span><span style="color: #2b91af; font-size: x-small;">KeyValuePair</span><span style="font-size: x-small;">&lt;</span><span style="color: #0000ff; font-size: x-small;">string</span><span style="font-size: x-small;">, </span><span style="color: #0000ff; font-size: x-small;">object</span><span style="font-size: x-small;">&gt; kvp </span><span style="color: #0000ff; font-size: x-small;">in</span><span style="font-size: x-small;"> e.WhereParameters)<br />
</span><span style="font-size: x-small;">{</span></p>
<p><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;"> (kvp.Value == </span><span style="color: #0000ff; font-size: x-small;">null</span><span style="font-size: x-small;">){</span></p>
<p><span style="font-size: x-small;"> e.Cancel = </span><span style="color: #0000ff; font-size: x-small;">true</span><span style="font-size: x-small;">;</span></p>
<p><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;">;</span></p>
<p><span style="font-size: x-small;"> }</span></p>
<p><span style="font-size: x-small;">}</span></p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="font-size: x-small;">Problem solved.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/02/05/operator-incompatible-with-operand-types-int32-and-object/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

