title: multiple conditions Linq extended
body: <p>I need to consider multiple  conditions to get value.
  i mean if all conditions true that must give me a filtered answer.
  Or one of them is true,rest are false...
  so i need to write all possibilities??
  if(a&amp;b&amp;c&amp;d) else if(a&amp;b&amp;c) else if(a&amp;c&amp;d) else if(b&amp;c&amp;d) else if(a&amp;b) else if (a&amp;c)...etc ?? :))) Is there a shorter way to do this?</p>
  
  <pre><code>    public List&lt;ProductReqNoDate&gt; GetRequestsQuery(string departmant, int reqStateID, string firstDate, string lastDate, string productName)
      {
          var db = new requestDBEntities();
          bool dp = !string.IsNullOrEmpty(departmant);
          bool pr = !string.IsNullOrEmpty(productName);
          bool tm = !string.IsNullOrEmpty(firstDate) &amp;&amp; !string.IsNullOrEmpty(lastDate);
          bool rs = reqStateID &gt; 0 ? true : false;
  
          var query = (from r in db.requests
                       select new ProductReqNoDate
                       {
                           departmant = r.departmant,
                           reqNo = r.reqNo,
                           reqDate = r.reqDate,
                           productName = (from p in db.products where p.reqNo == r.reqNo select p.productName).FirstOrDefault()
                       }).ToList();
          if (dp &amp; pr &amp; tm &amp; rs)
          {
              var rState = (from ta in db.reqStates
                            where ta.reqStateID == reqStateID &amp;&amp; ta.isActive == true
                            select ta.reqNo).ToList();
              var prName = (from p in db.products where p.productName.Contains(productName) select p.reqNo).ToList();
              DateTime dtfirstDate = Convert.ToDateTime(firstDate);
              DateTime dtlastDate = Convert.ToDateTime(lastDate);
  
              return query.Where(
                  r =&gt; rState.Contains(r.reqNo)  //find by Request State
                    &amp;&amp; r.departmant == departmant  //find by Departmant
                     &amp;&amp; (r.reqDate &gt;= dtfirstDate &amp;&amp; r.reqDate &lt;= dtlastDate) //find by Date
                      &amp;&amp; prName.Contains(r.reqNo) //Find By Product Name
                      ).ToList();
  
          }
          else if (dp &amp; pr &amp; tm) { /*return query.Where(...} */}
          else if (pr &amp; tm &amp; rs) { /*return query.Where(...} */}
          else if (dp &amp; pr &amp;&amp; rs) { /*return query.Where(...} */}
          else if (dp &amp; pr) { /*return query.Where(...} */}
          //else if ...etc
      }
  </code></pre>