 <p><strong>First:</strong> I would really re-check your original code for the conditions, while its possible there is a bug in the query optimizer its more likely there was a bug on the expression used and it really didn't represent the below:</p> <blockquote> <p>var DesiredList = db.Things.Where(t=> condition1 || (!condition1 &amp;&amp; condition2));</p> <p>the problem is query optimizer seems to trim the expression to condition2 only.</p> </blockquote> <p>That should really give you the ones that match condition1 regardless of condition2 ... and ones that don't match condition1 and match condition2. Instead condition2 alone is not equivalent because that leaves out records that only match condition1. </p> <p>JS version of just (condition1 || condition2) is equivalent to the quoted expression above, as when u are matching condition1 you are already matching both condition2 and !condition2 so you are already including condition2 for both condition1 and !condition1 cases. If this doesn't match what you intended with the queries, is then clearer that's not an issue with the optimizer but with the original expressions.</p> <p>You would only need the full expressions if you were joining 2 results with a Concat instead of Union, as that would mean you would end up with results matching in both expressions ... and then you would have repeated results. But in contrast, the Where is evaluated per row, so you don't have those concerns in there.</p> <hr> <p><strong>Second:</strong> From the code sample, I think what you are facing is less direct of what you are going after in your question. You mentioned you are getting the first tag, but what you are really doing can be seen in this re-written version:</p> <pre><code>public static IQueryable&lt;BookTag&gt; UniqueByTags(this IQueryable&lt;BookTag&gt; bookTags, User user) { return bookTags.GroupBy(BT =&gt; BT.TagId) .Select(g =&gt; new BookTag() { User = g.Any(bt =&gt; bt.UserId == user.Id) ? user : g.First().User, Tag = g.First().Tag, Book = bookTags.First().Book }); } </code></pre> <p>What's mentioned in the comment seems more like:</p> <pre><code>public static IQueryable&lt;BookTag&gt; UniqueByTags(this IQueryable&lt;BookTag&gt; bookTags, User user) { return bookTags.GroupBy(BT =&gt; BT.TagId) .Select(g =&gt; g.Any(bt =&gt; bt.UserId == user.Id) ? g.First(bt=&gt;bt.UserId == user.Id) : g.First() ); } </code></pre>