title: LINQ: differences between single Where with multiple conditions and consecutive Wheres with single condition
body: <p>Is there any disadvantage in concatenating multiple <code>Where</code> in LINQ instead of using a single <code>Where</code> with multiple conditions?</p>
  
  <p>I'm asking because using multiple <code>Where</code> can help to reduce complexity and improve maintainability of my code considerably.</p>
  
  <p>Consider following code, <code>chargeList</code> is a <code>List&lt;Charge&gt;</code> which is the source of a <code>BindingSource</code>:</p>
  
  <pre><code>IEnumerable&lt;Charge&gt; matchingCharges = chargeList;
  if(!string.IsNullOrWhiteSpace(channelAbbr))
      matchingCharges = matchingCharges
          .Where(c =&gt; c.ChannelAbbreviation == channelAbbr);
  if(deliveryNoteDate.HasValue)
      matchingCharges = matchingCharges
          .Where(c =&gt; c.ArrivalAt == deliveryNoteDate.Value);
  if(chargeID.HasValue)
      matchingCharges = matchingCharges
          .Where(c =&gt; c.ChargeID == chargeID.Value);
  </code></pre>
  
  <p>This concise code will handle all combinations of filter, none,one,two,all.</p>
  
  <p>Otherwise i'd have to use <code>if-else</code> and multiple conditions in a single <code>Where</code>.</p>
  
  <p>This is the best that comes to my mind:</p>
  
  <pre><code>// important to keep code readable:
  bool filterChannel = !string.IsNullOrWhiteSpace(channelAbbr);
  bool filterDate = deliveryNoteDate.HasValue;
  bool filterID = chargeID.HasValue;
  
  if(!filterChannel &amp;&amp; !filterDate &amp;&amp; !filterID)
  {
      // take all 
      matchingCharges = chargeList;
  }
  else
  {
      matchingCharges = chargeList
          .Where(c =&gt; 
              filterChannel ? c.ChannelAbbreviation == channelAbbr : true
              &amp;&amp; filterDate ? c.ArrivalAt == deliveryNoteDate.Value : true
              &amp;&amp; filterID   ? c.ChargeID ==  chargeID.Value : true);
  }
  </code></pre>
  
  <p>So what are the differences between both, are they negligible? Does the LINQ provider matter? </p>