title: Using ISNULL on an int? in the WHERE clause of Linq queries
body: <p>I have been trying to find a resolution to this and I've seen many examples of how to use the <code>ISNULL</code> functionality in a <code>SELECT</code> statement, or how to check for nulls in a <code>WHERE</code> clause to return a boolean value. </p>
  
  <p>However I can't find any examples through my searches of how to return an integer depending on whether or not the value is null.</p>
  
  <p>I'm trying to replicate a simple piece of functionality from SQL:</p>
  
  <pre><code>SELECT * 
  FROM Projects 
  WHERE ISNULL(projects.ParentID , 0) = @Value
  </code></pre>
  
  <p>I've tried a few different methods based on suggestions I've seen relating to <code>SELECT</code> clauses or <code>ISNULL</code> boolean operations in the <code>WHERE</code> clause throughout my searches:</p>
  
  <pre><code>var output = (from p in ctx.Projects...
  </code></pre>
  
  <p>1.</p>
  
  <pre><code>...
  where ( (p.ParentID == null) ? p.ParentID == 0 : p.ParentID == p.ParentID) == @var 
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>...
  where p.ParentID ?? 0 == @var
  </code></pre>
  
  <p>3.</p>
  
  <pre><code>...
  where p.ParentID ? 0 == @var
  </code></pre>
  
  <p>4.</p>
  
  <pre><code>...
  where ((p.ParentID == null) ? true : 0 ) == @var
  </code></pre>
  
  <p>5.</p>
  
  <pre><code>...
  where 
  ((p.ParentID == null) ? 0 ) == @var
  </code></pre>
  
  <p><code>...select p</code> )</p>
  
  <p>Any help would be appreciated, I'm at a loss as to why this is so complex in Linq compared to SQL. </p>