<?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>Emad Alashi&#039;s Blog &#187; NHibernate IQuery bug IList</title>
	<atom:link href="http://www.emadashi.com/index.php/tag/nhibernate-iquery-bug-ilist/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emadashi.com</link>
	<description></description>
	<lastBuildDate>Sun, 15 Jan 2012 10:05:42 +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>NHibernate possible bug in IQuery.List&lt;T&gt;()</title>
		<link>http://www.emadashi.com/index.php/2008/09/nhibernate-possible-bug-in-iquerylistt/</link>
		<comments>http://www.emadashi.com/index.php/2008/09/nhibernate-possible-bug-in-iquerylistt/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 22:09:15 +0000</pubDate>
		<dc:creator>Emad Alashi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[NHibernate IQuery bug IList]]></category>

		<guid isPermaLink="false">http://eashi.wordpress.com/2008/09/22/nhibernate-possible-bug-in-iquerylistt/</guid>
		<description><![CDATA[recently, we had to clean the database from all the testing data, when an error similar to the following appeared:
The value &#8220;&#8221; is not of type &#8220;System.Nullable`1[System.DateTime]&#8221; and cannot be used in this generic collection
The code I executed was:

            IQuery query = DbManager.MySession.CreateQuery(&#8220;select max(dateObject.EndDate) from DateDomain dateObject&#8221;);
            IList&#60;DateTime?&#62; list = query.List&#60;DateTime?&#62;();

When I debugged NHibernate code, [...]]]></description>
			<content:encoded><![CDATA[<p>recently, we had to clean the database from all the testing data, when an error similar to the following appeared:</p>
<p><strong>The value &#8220;&#8221; is not of type &#8220;System.Nullable`1[System.DateTime]&#8221; and cannot be used in this generic collection</strong></p>
<p>The code I executed was:</p>
<div style="font-size:12pt;background:#f2ebe3;color:black;font-family:courier new;">
<p style="margin:0;"><span style="color:#2b91af;">            IQuery</span> query = <span style="color:#2b91af;">DbManager</span>.MySession.CreateQuery(<span style="color:#a31515;">&#8220;select max(dateObject.EndDate) from DateDomain dateObject&#8221;</span>);</p>
<p style="margin:0;">            <span style="color:#2b91af;">IList</span>&lt;<span style="color:#2b91af;">DateTime</span>?&gt; list = query.List&lt;<span style="color:#2b91af;">DateTime</span>?&gt;();</p>
</div>
<p>When I debugged NHibernate code, I reached to the following AddAll() method in the ArrayHelper class:</p>
<div style="font-size:12pt;background:#f2ebe3;color:black;font-family:courier new;">
<p style="margin:0;"><span style="color:#2b91af;">  152</span> <span style="color:#008000;">// NH-specific</span></p>
<p style="margin:0;"><span style="color:#2b91af;">  153</span>         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> AddAll(<span style="color:#2b91af;">IList</span> to, <span style="color:#2b91af;">IList</span> from)</p>
<p style="margin:0;"><span style="color:#2b91af;">  154</span>         {</p>
<p style="margin:0;"><span style="color:#2b91af;">  155</span>             <span style="color:#0000ff;">foreach</span> (<span style="color:#0000ff;">object</span> obj <span style="color:#0000ff;">in</span> from)</p>
<p style="margin:0;"><span style="color:#2b91af;">  156</span>             {</p>
<p style="margin:0;"><span style="color:#2b91af;">  157</span>                 to.Add(obj);</p>
<p style="margin:0;"><span style="color:#2b91af;">  158</span>             }</p>
<p style="margin:0;"><span style="color:#2b91af;">  159</span>         }</p>
</div>
<p>You can find the explanation of the error <a href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/abc99fb5-e218-4efa-8969-3d96f6021cee/">here</a>.<br />
Which brings us to the interesting question: why the implementation of IList Add method doesn&#8217;t consider the &#8220;nullability&#8221; of the T object? and why the parameter is of type IList ?!</p>
<p> Am I missing something? should I report it as a bug?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emadashi.com/index.php/2008/09/nhibernate-possible-bug-in-iquerylistt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

