title: How to convert a search string to a boolean condition?
body: <p>I have a search criteria stored in a string:</p>
  
  <pre><code>string Searchstr = "(r.Value.Contains("PwC") || (r.Value.Contains("Canadian") &amp;&amp; r.Value.Contains("thrive"))) || (r.Value.Contains("Banana") &amp;&amp; r.Value.Contains("Gayle"))"
  </code></pre>
  
  <p>I want to use this in a If statement to check the values:</p>
  
  <pre><code>if(searchstr)
  {
    then do this....
  }
  </code></pre>
  
  <p>but the if should have a searchstr as boolean.</p>
  
  <p>How to convert this to boolean?</p>
  
  <p>EDIT: The requirement is to give search criteria dynamically in a text box in the following format - "PwC OR (Canadian AND thrive)".
  Which will be used to search an XML file.</p>
  
  <p>Therefore I have loaded an XML file and want to have a Where condition in LINQ for which I need to use Dynamic LINQ but string is not allowed in that and also I have some braces to deal with.</p>
  
  <p>Thinking of that I have taken the resultset from the XML(The tag value which i need to search)</p>
  
  <pre><code>var selectedBook = from r in document.Root.Descendants("Archives").Elements("Headline").Elements("Para")
                                     select r;
  </code></pre>
  
  <p>and would ideally like to try something like:</p>
  
  <pre><code>var query=selectedbook.Where(searchstr)
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>if(searchstr){....then do this}
  </code></pre>