title: Search function LINQ. Use checkbox values as parameters
body: <p>I have a search function that tales 7 parameters and 6 of them are checkbox values. They are bools like shown down below. I Have a problem with my datetime search. If the user check that box if would like do run a serach function where that a date is not null in the database. My code look like this at the moment. But i would like to get some feedback to how to improve my code for better performance and code structure.</p>
  
  <pre><code>public List&lt;Invoice&gt; GetAllInvoicesBySearch(int merchant, long buyer, bool send, bool paid, bool firstReminder, bool secondReminder, bool invoiceClaim)
      {
          var sendValue = new InvoiceStatus();
          var paidValue = new InvoiceStatus();
          var firstRemind = new DateTime();
          var secondRemind = new DateTime();
          if (buyer &lt;= 0)
          {
              return null;
          }
          if (send)
          {
               sendValue = InvoiceStatus.Sent;
          }
          if (paid)
          {
              paidValue = InvoiceStatus.Paid;
          }
          if (firstReminder)
          {
              firstRemind = DateTime.Now;
          }
          if (secondReminder)
          {
              secondRemind = DateTime.Now;
          }
  
          return
              Context.Invoices.Where(
                  i =&gt;
                     i.InstallationId == merchant &amp;&amp; i.Buyer.Msisdn == buyer || i.Status == sendValue || i.Status == paidValue ||
                      i.FirstReminderDate == firstRemind || i.SecondReminderDate == secondRemind).ToList();
      }
  </code></pre>
  
  <p>So my problem is with the datetime at the moment to get that correctly. Any suggestions on how to solve my problem and improve my code?</p>