title: Using ternary operator to check if null - null reference is not the same as null
body: <p>I am attempting to use the ternary operator to check if a value is null and return one expression or the other. What I'm experiencing when incorporating this into a LINQ expression is that the Transact-SQL translation of the LINQ expression attempts to do a "column = null" rather than a "column IS NULL". I have reason to believe that this is because I'm doing the following:</p>
  
  <pre><code>mappedColumnName == (myVar == null ? null : myOtherVar)
  </code></pre>
  
  <p>Since it translates the following to columnName IS NULL in Transact-SQL:</p>
  
  <pre><code>mappedColumnName == null
  </code></pre>
  
  <p>Does anyone have any experience with this? I'd very much like to get this to work.</p>
  
  <p>The entire LINQ expression:</p>
  
  <pre><code>(from MenuItem in menuContext.Menus
     where MenuItem.IsSysAdmin == (ClientID == 1 ? true : false)
     &amp;&amp; MenuItem.IsActive == true
     &amp;&amp; MenuItem.ParentMenuCode == (ActiveSubMenu==null?null:ActiveMenu)
     &amp;&amp; MenuItem.ClientID == (UseClientMenu ? ClientID : 0)
     &amp;&amp; MenuItem.EmployeeID == (UseEmployeeMenu ? EmployeeID : 0)
     orderby MenuItem.SortOrder, MenuItem.MenuName
     select MenuItem);
  </code></pre>