title: Construct expression for where through lambdas
body: <p><strong>The situation</strong></p>
  
  <p>I have a method that takes in a POCO. This POCO is like the following</p>
  
  <pre><code>    private class SearchCriteria
      {
        public string name get;set;
        public string age get;set;
        public string talent get;set;
      .. 
  .... 
       }
  </code></pre>
  
  <p>The method basically has a query to the db , that uses the above criteria.</p>
  
  <pre><code>public void query(SearchCriteria crit)
  {
    if(crit.name!=null &amp;&amp; crit.age!=null &amp;&amp; crit.talent !=null)
     {
       dbContext.Students.Where(c=&gt;c.name ==crit.name &amp;&amp;    c.age==crit.age...)
     }
    else if(crit.name !=null &amp;&amp; crit.age!=null)
    {
    }
    else if(....
    {
    }
  </code></pre>
  
  <p>As you can see there is a definite problem above , where in, in case of large number of criteria, I will have to write a lot of if-elses to drop out specific arguments from the where clause . </p>
  
  <p><strong>The possible solution ?</strong></p>
  
  <p>I am actually new to the lambda expressions world but I believe we must be having a facility which would allow us to do something like below.</p>
  
  <p><code>dbContext.Students.Where(processCriteria(searchCriteriaPOCO))</code>.</p>
  
  <p>Can you folks lead me to the proper direction ?. Thanks</p>