title: Dynamic build lambda expressions
body: <p>So, I started to build a small test application to test lambda expressions. I found several examples here and elsewhere but I just don't get them.</p>
  
  <p>Can anybody explain my how to build an expression by using textboxes or any other variables?</p>
  
  <p>My Test List</p>
  
  <pre><code>List&lt;People&gt; lPeople = new List&lt;People&gt; 
  {
      new People { Name= "Jean", LastName = "Borrow", Age= 21 } ,
      new People { Name= "Dean", LastName = "Torrow", Age= 20 }
  };
  </code></pre>
  
  <p>Working lambda Expression</p>
  
  <pre><code>IEnumerable&lt;People&gt; result = lPeople.Where(p =&gt; p.Age &lt; 21);
  dgv_1.DataSource = result.ToList();
  dgv_1.Update();
  </code></pre>
  
  <p>How can I build the expressions dynamically? </p>
  
  <p>Something like <code>lPeople.Where(p =&gt; p.LastName == Textbox.Text);</code> (which of course doesn't work)</p>
  
  <p>Thanks!</p>
  
  <p>Edit: Added some code to the solution below</p>
  
  <pre><code>Int32 iAge;
  Boolean bSuc = Int32.TryParse(tb_filter_age.Text, out iAge);
  if (!bSuc)
  {
      iAge = 0;
  }
  </code></pre>