title: Lambda Expression if-else statement in where clauses
body: <p>I want to change where clauses with  paremeter.Example i have 2 string variable. </p>
  
  <pre><code>string searchText="John";
  string userField="Name"//it can be ID,UserName or Email
  </code></pre>
  
  <p>I want to change  Users property(a.Name) based on "string userField="Name"/"</p>
  
  <pre><code>var a entities.Users
       where a.Name==searchText    //a.Name(Name) is declared in userField. It can be ID,UserName or Email                     
  </code></pre>
  
  <p>My code is shown below:</p>
  
  <pre><code>var users = new
                 {
                     total = 10,
                     page = page,
                     record = (entities.Users.Count()),
                     rows = (from user in entities.Users
                             select new
                             {
                                 ID = user.ID,
                                 Name = user.Name,
                                 UserName = user.UserName,
                                 UserType = user.Role.Name,
                                 Email = user.Email,
                                 CreatedDate = user.CreatedDate,
                                 UpdatedDate = user.UpdatedDate
                             }).AsEnumerable().Select(m =&gt; new { ID = m.ID, Name = m.Name, UserName  = m.UserName, Email = m.Email, UserType = m.UserType, CreatedDate = String.Format("{0:d/M/yyyy  HH:mm:ss}", m.CreatedDate), UpdatedDate = String.Format("{0:d/M/yyyy HH:mm:ss}", m.UpdatedDate) }),
                 }; 
  </code></pre>
  
  <p>How can i do that with this lambada expression?</p>