title: Null Checks for long datatype in Linq
body: <p>I am working on a problem where I need to first query the database to determine if the input record will result in 'overlapping' date spans. Fairly simple task in SQL, but I cannot seem to get it to work in Linq. Here are the relevant business rules:</p>
  
  <p>If Id1 == Id1 and the datespans overlap, then bring me back the record(s) that conflict
  If Id2 == Id2 and the datespans overlap, then bring me back the record(s) that conflict
  If Id1 == null and Id2 == null and the datespans overlap, then bring me back the records that conflict.</p>
  
  <p>My linq query is as follows:</p>
  
  <pre><code>resultingOverlaps = (from overlapSpans in entities.ENTITIES
               where overlapSpans.CNTRCT_TYP_ID == contractId
               where (overlapSpans.ID1 == Id1 || overlapSpans.Id2 == Id2 ||
                     (overlapSpans.ID1 == null &amp;&amp; overlapSpans.Id2 == null))
               where (
               (overlapSpans.EFF_DT &lt; effDate &amp;&amp; overlapSpans.END_DT &gt;= effDate)
                || (overlapSpans.EFF_DT &gt; effDate &amp;&amp; overlapSpans.EFF_DT &lt;= endDate)
                || (overlapSpans.EFF_DT == effDate)
               )
               select overlapSpans).ToList();
  </code></pre>
  
  <p>The issue is that Id1 and Id2 are the datatype long?, and thus cannot be checked for null in this manner, or any other manner that I have tried so far. (testing for 0, using '.HasValue', etc.)</p>
  
  <p>How do you check for null values that have a long datatype?</p>