title: Entity Framework Core LINQ query with multiple where clauses
body: <p>I need some sample code for my project. I am working with EF CORE 2.1.1. </p>
  
  <p>I created a function which accepts 3 parameters, inside that function I am executing a LINQ (lambda expression query), returning a list.</p>
  
  <p>Here is my function :</p>
  
  <pre><code>public IEnumerable&lt;Donneesource&gt; GetAllSourcesFromBDD(DateTime PremierDateCom, DateTime DerniereDateCom, string Secteur)
  {
      try
      {
          //Récupération des données.
               IEnumerable&lt;Donneesource&gt; RawDatas = _sourceDAL.Donneesource
                  .Where(ic =&gt; ic.EstCopieDestination == false)
                  .Where(s =&gt; PremierDateCom != DateTime.MinValue &amp;&amp; s.SComPremierDate.Value.Date == PremierDateCom.Date)
                  .Where(s =&gt; DerniereDateCom != DateTime.MinValue &amp;&amp; s.SComDerniereDate.Value.Date == DerniereDateCom.Date)                    
                  .Where(s =&gt; Secteur != string.Empty &amp;&amp; s.SSectNom == Secteur)
                  .ToList();
  
          return RawDatas;              
      }
      catch(Exception)
      { 
          return null;
      }
  }
  </code></pre>
  
  <p>By default I set DateTime params to DateTime.MinValue (PremierDateCom,DerniereDateCom) and string param to string.Empty (Secteur).</p>
  
  <p>I am trying to create a <strong>single</strong> query with where clauses. I want to ignore the where clauses with default params. For example If PremierDateCom = DateTime.MinValue (or other params) then I want to ignore the where clauses if something I want to include my where clause in my query. </p>
  
  <p>I don't want to create a query like this:</p>
  
  <pre><code>  //Filtre
              if (PremierDateCom != DateTime.MinValue)
                  RawDatas = RawDatas.Where(x =&gt; x.SComPremierDate.Value.ToShortDateString() == PremierDateCom.ToShortDateString());
              //Filtre
              if (DerniereDateCom != DateTime.MinValue)
                  RawDatas = RawDatas.Where(x =&gt; x.SComDerniereDate.Value.ToShortDateString() == DerniereDateCom.ToShortDateString());   
              //Filtre                
              if (Secteur != null)
                  RawDatas = RawDatas.Where(x =&gt; x.SSectNom == Secteur);
  </code></pre>