title: Nullable value in query
body: <p>I need get all items these have no categories</p>
  
  <pre><code>int? categoryId = null;
  var items=db.Items.Where(x=&gt;x.CategoryId==categoryId);
  </code></pre>
  
  <p>This code generate in where: </p>
  
  <pre><code>where CategoryId=null
  </code></pre>
  
  <p>Instead of</p>
  
  <pre><code>where CategoryId is null
  </code></pre>
  
  <p>Ok, when I write</p>
  
  <pre><code>var items=db.Items.Where(x=&gt;x.CategoryId==null);
  </code></pre>
  
  <p>In my sql profiler it works:</p>
  
  <pre><code>where CategoryId is null
  </code></pre>
  
  <p>But when I do this hack it doesn't work:</p>
  
  <pre><code>var items=db.Items.Where(x=&gt;x.CategoryId==(categoryId.HasValue ? categoryId : null));
  </code></pre>
  
  <p>So what's the problem? Is there by in L2S?</p>
  
  <p>Update: if categoryId has value it need return something like this:</p>
  
  <pre><code>where CategoryId = 1
  </code></pre>