title: Lambda Expressions and the || operator in Entity Framework
body: <p>I was surprised that this code works:</p>
  
  <pre><code>string category = null;
  Category Category = null;
  int categoryId = 0;
  
  var products = repository.Products
      .Where(p =&gt; category == null || p.CategoryID == categoryId)
      .ToList();
  </code></pre>
  
  <p>yet the code below <strong>fails</strong>:</p>
  
  <pre><code>string category = null;
  Category Category = null;
  int categoryId = 0;
  
  var products = repository.Products
      .Where(p =&gt; category == null || p.CategoryID == Category.CategoryID)
      .ToList();
  </code></pre>
  
  <p>I know the issue is that even though I'm using the || operator-- it doesn't quite work as I would think it would. </p>
  
  <p>In the second example Why does Category get looked at-- even though the category value is null. Wouldn't it get short circuited?</p>