<p>Starting with the following LINQ query:</p>

<pre><code>from a in things  
where a.Id == b.Id &amp;&amp;  
a.Name == b.Name &amp;&amp;  
a.Value1 == b.Value1 &amp;&amp;  
a.Value2 == b.Value2 &amp;&amp;  
a.Value3 == b.Value3  
select a;
</code></pre>

<p>How can I remove (at runtime) one or more of the conditions in the where clause in order to obtain queries similar to the following ones:</p>

<pre><code>from a in things  
where a.Id == b.Id &amp;&amp;  
a.Name == b.Name &amp;&amp;  
a.Value2 == b.Value2 &amp;&amp;  
a.Value3 == b.Value3  
select a;
</code></pre>

<p>Or</p>

<pre><code>from a in things  
where 
a.Name == b.Name &amp;&amp;  
a.Value3 == b.Value3  
select a;
</code></pre>

Rather than try to change existing where clauses, I'd refactor it to this:
```
```
from a in things  
where a.Id == b.Id 
where a.Name == b.Name 
where a.Value1 == b.Value1
where a.Value2 == b.Value2
where a.Value3 == b.Value3  
select a;
```
```
That then becomes:
```
```
things.Where(a => a.Id == b.Id)
      .Where(a => a.Name == b.Name)
      .Where(a => a.Value1 == b.Value1)
      .Where(a => a.Value2 == b.Value2)
      .Where(a => a.Value1 == b.Value3);
```
```
Now it should be reasonably clear how to proceed - conditionalise the calls to Where:
```
```
IQueryable<Whatever> query = things;
if (useId) {
    query = query.Where(a => a.Id == b.Id);
}
query = query.Where(a => a.Name == b.Name);
if (checkValue1) {
    query = query.Where(a => a.Value1 == b.Value1);
}
// etc
```
```