<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Tags/NHibernate IQuery Bug IList on Emad Alashi</title>
    <link>https://emadashi.com/tags/nhibernate-iquery-bug-ilist/</link>
    <description>Recent content in Tags/NHibernate IQuery Bug IList on Emad Alashi</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sun, 21 Sep 2008 22:09:15 +0000</lastBuildDate>
    <atom:link href="https://emadashi.com/tags/nhibernate-iquery-bug-ilist/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>NHibernate possible bug in IQuery.List&lt;T&gt;()</title>
      <link>https://emadashi.com/2008/09/nhibernate-possible-bug-in-iquerylistt/</link>
      <pubDate>Sun, 21 Sep 2008 22:09:15 +0000</pubDate>
      <guid>https://emadashi.com/2008/09/nhibernate-possible-bug-in-iquerylistt/</guid>
      <description>&lt;p&gt;recently, we had to clean the database from all the testing data, when an error similar to the following appeared:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The value &amp;quot;&amp;quot; is not of type &amp;ldquo;System.Nullable`1[System.DateTime]&amp;rdquo; and cannot be used in this generic collection&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The code I executed was:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-csharp&#34; data-lang=&#34;csharp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;IQuery query = DbManager.MySession.CreateQuery(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;select max(dateObject.EndDate) from DateDomain dateObject&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;IList&amp;lt;DateTime?&amp;gt; list = query.List&amp;lt;DateTime?&amp;gt;();
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When I debugged NHibernate code, I reached to the following AddAll() method in the ArrayHelper class:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-csharp&#34; data-lang=&#34;csharp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// NH-specific&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;public&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;static&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; AddAll(IList to, IList &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;foreach&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;object&lt;/span&gt; obj &lt;span style=&#34;color:#66d9ef&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        to.Add(obj);
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can find the explanation of the error &lt;a href=&#34;http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/abc99fb5-e218-4efa-8969-3d96f6021cee/&#34;&gt;here&lt;/a&gt;.&lt;br&gt;
Which brings us to the interesting question: why the implementation of IList Add method doesn&amp;rsquo;t consider the &amp;ldquo;nullability&amp;rdquo; of the T object? and why the parameter is of type IList?!&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
