Define a column as nullable in System.Data.DataTable
<p>I need to define a <code>System.Data.DataTable</code> in C# VS2013; in one column, it may be int or null.</p>
<p>But I got:</p>
<blockquote>
<p>DataSet does not support System.Nullable&lt;&gt;.</p>
</blockquote>
<p>For the definition:</p>
<pre><code>public DataTable myDataTable
myDataTable = new DataTable(&quot;myName&quot;);
myDataTable.Columns.Add(&quot;ID&quot;, typeof(Int32)); 
myDataTable.Columns.Add(&quot;value1&quot;, typeof(Int32?)); // run time error 
myDataTable.Columns.Add(&quot;value2&quot;, typeof(Int32?)); 
</code></pre>
<p>Any ideas? Work around?</p>
<p>After making the column nullable,</p>
<pre><code>DataColumn dc = myDataTable.Columns.Add(&quot;value1&quot;, typeof(Int32));
dc.AllowDBNull = true;
</code></pre>
<p>When I queried it, I got</p>
<blockquote>
<p>Sequence contains no elements.</p>
</blockquote>
<p>Please see the UPDATE.</p>
<p><strong>UPDATE</strong></p>
<pre><code>int? result = (from r in myDataTable.AsEnumerable()
               where r.Field&lt;Int32&gt;(&quot;ID&quot;) == givenID
                   &amp;&amp; r.Field&lt;Int32?&gt;(&quot;value1&quot;) == givenValue1
               select r.Field&lt;Int32&gt;(&quot;value2&quot;)).First();
</code></pre>