title: best practice for retrieving data which meet selected conditions
body: <p>I have a database table named call with columns call_time, location, emergency_type and there are three types of emergency: paramedics, police and firefighters. In the windows form I created CheckBoxes 'paramedics', 'police', 'firefighters' and I want to retrieve all table columns which meet user's selection.</p>
  
  <p>I created a function:</p>
  
  <pre><code>public static DataTable GetHistory(DateTime from, DateTime to, bool paramedics, bool police, bool firefighters)
      {
          string select =
              "SELECT call_time, location, emergency_type where call_time between @from AND @to AND";
          if(paramedics)
          {
              select += " emergency_type = 'paramedics' ";
          }
          if(paramedics &amp;&amp; police)
          {
             select +=" emergency_type = 'paramedics' OR emergency_type = 'police';
          }
          ...
  
      }
  </code></pre>
  
  <p>This code however seems very dirty because if there were 30 kinds of emergency there would be 30! combinations and I would get old before writing all if statements.</p>
  
  <p>I would appreciate if you shared your practice for retrieving data that meet the selected search conditions if there are many options you can chosse.</p>
  
  <p>Thanks!</p>