I am not sure weather its possible or not but I have to do it in my project somehow. I am getting one condition in string format like:
string condition = "(param1='69' OR param1='66' OR param1='21' OR param1='93') AND (param2='FL' OR param2='WA) AND (param3!='31' AND param3!='19')";
This condition I am getting from db and I have value of param1, param2 and param3 in my code. Now I have to check this condition in a if statement weather its true of false and show result accordingly.
I try like replacing param1, param2, param3 with actual value lets say 69, CA, 22. So the string will look like:
condition = "(69='69' OR 69='66' OR 69='21' OR 69='93') AND (CA='FL' OR CA='WA) AND (22!='31' AND 22!='19')";
and try to convert it in bool also but its not working.
Please let me know if there is any way or else I need to hardcode it? One more thing, condition might very, like sometimes it will come with 2 variable or sometimes with four.
=into==except when they're part of!=; then allORto||and allANDto&&. Then you "just" need to evaluate that string as an expression... maybe this will help with that: stackoverflow.com/questions/53844/…condition = condition.Replace("param1", "'" + param + "'");