title: Linq null value not comparing
body: <p>Scenario is that I need to check each column of a row to see if it contains a userID. I only want to be able to insert a userID into a column if it does NOT exist in any other column.</p>
  
  <p>Table is like:</p>
  
  <pre><code>Col1 = ID (PK)
  Col2 = No1 varchar(50) ..... also tried GUID
  Col3 = No2 varchar(50) ..... also tried GUID
  Col4 = No3 varchar(50) ..... also tried GUID
  </code></pre>
  
  <p>Default value of each column is null bar the ID which is auto. </p>
  
  <p>So current state of the table is:</p>
  
  <pre><code>1  NULL  NULL  NULL
  2  NULL  NULL  NULL
  3  NULL  2     NULL
  </code></pre>
  
  <p>What I want to do is insert the userID value into the selected column on the proviso that the userID does not exist in any of the other columns.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>mymodel m = new mymodel()
  m = db.mytable.Where(t =&gt; 
  t.id == id &amp;&amp; 
  t.No1 != userID &amp;&amp;
  t.No2 != userID &amp;&amp;
  t.No3 != userID).First();
  </code></pre>
  
  <p>The idea is to check for an entry first and then run an update.</p>
  
  <p>Now when I run this and all columns are null I get nothing back.
  When I run it on row 3 (which has userID in col 2) I also get nothing.</p>
  
  <p>If this was SQL straight I would likely put an isnull(userID, '') wrapper on the userID, but as far as I am aware this is not possible in Linq. </p>
  
  <p>I cannot check for NULL (i.e. t.No2 != userID &amp;&amp; t.No2 == NULL) because this means that I will be able to insert a userID into a row that already has said userID already in another column.</p>
  
  <p>Is my only option to design the database to have a default value of '' in each of the columns to enable Linq to compare NULL?</p>