title: LINQ query checks for null
body: <p>I have a userList, some users don't have a name (null).  If I run the first LINQ query, I got an error saying "object reference not set to an instance of an object" error.</p>
  
  <pre><code>var temp = (from a in userList
              where ((a.name == "john") &amp;&amp; (a.name != null))
              select a).ToList();
  </code></pre>
  
  <p>However, if I switch the order by putting the checking for null in front, then it works without throwing any error:</p>
  
  <pre><code>var temp = (from a in userList
              where ((a.name != null) &amp;&amp; (a.name == "john"))
              select a).ToList();
  </code></pre>
  
  <p>Why is that? If that's pure C# code (not LINQ), I think both would be the same. I don't have SQL profiler, I am just curious what will be the difference when they are being  translated on SQL level.</p>