Evaluating string expressions

Feb 10, 2010 at 6:40 AM


Is there any documentation that I can refer? I wan to evaluate an expression similar to the following one. It has a string variable ProductName and a decimal variable Price. Is it possible to evaluate this expression using ExpressionEval?

var sExp = "(ProductName == \"My Dummy Product\" AND Price > 500) OR (ProductName != \"My Dummy1\" AND Price > 9000)";

Thank you


May 18, 2010 at 8:07 PM

ExpressionEval is based on C# lambda syntax so you should use something like this:

// create expression eval instance
Expression> filter = new ExpressionEval(
"(item.ProductName == \"My Dummy Product\" && item.Price > 500) || (item.ProductName != \"My Dummy1\" && item.Price > 900")
					// add item parameter
					// create lambda expression
// now compile expression and invoke with parameter
bool isFilterValid = filter.Compile().Invoke(productInstance);

May 19, 2010 at 5:11 PM
I totally forgot why I had asked this question. Thanks for replying anyway. :)