title: If statements within a Linq where clause
body: <p>Struggling a bit today.</p>
  
  <p>I have the following method that returns a list of products..lovely.</p>
  
  <pre><code>public static List&lt;tblWeight&gt; GetProductInfo(string memberid, string locationid, string basematerial, string source)
          {
               MyEntities getproductinfo = new MyEntities ();
  
              return (from p in getproductinfo .tblWeights
                          where    p.MemberId == memberid &amp;&amp;
                                   p.LocationId == locationid &amp;&amp;
                                   p.BaseMaterialName == basematerial &amp;&amp;
                                   p.WeightStatus == source
                         select p)
                         .ToList();
  </code></pre>
  
  <ul>
  <li>Where basematerial &amp; source are drop down lists.</li>
  </ul>
  
  <p>How do I go about incorporating a few IF statements into the where clause? </p>
  
  <p>For example, if the basematerial ddl is not touched but an item in the source ddl is selected, the result would return everything associated with basematerial but filtered by the selected source.</p>
  
  <p>Does that even make sense?!</p>
  
  <p>I'm not even sure I am taking the correct approach - please forgive my ignorance. </p>