title: Ternary operator with Linq-to-SQL causing problems?
body: <p>I have the following Linq-to-SQL statement:</p>
  
  <pre><code>return db.Photos.SingleOrDefault(p =&gt; p.PhotoID == id
                                                &amp;&amp; includePending ? true : p.Live);
  </code></pre>
  
  <p>For includePending I am passing false. In the database, "Live" is true for all but 2 photos.</p>
  
  <p>However instead of returning one photo as expected, it returns ALL photos in the database except for 2! PhotoID is a primary key (thus can only be true for one item) and boolean logic states that FALSE AND TRUE = FALSE. So what's going on here? Why is it ignoring the <code>p.PhotoID == id</code> portion of my query?</p>