Using Microsoft Json Rules engine.
The following rule expressions parse without an issue:
- "Names[0].PersonName.FirstName=="Paul""
- Names.Any()
but 3. throws the following parse exception
- "Names.Any(n=>n.PersonName.FirstName=="Paul")"
Exception while parsing expression Names.Any( n => n.PersonName.FirstName=="Paul") - Unable to cast object of type 'System.Linq.Expressions.InstanceMethodCallExpression1' to type 'System.Linq.Expressions.ParameterExpression'.
Dr. Google is not very helpful on this one.
Any feedback, directions, pointers etc. greatly appreciated.
I was expecting the expression to parse and when evaluated return, true, given 1. above is true.
Dynamic Linq using a operator called
"it"to refer to the current instance.aChanging the expression to the following:
"Names.Any(it.PersonName.FirstName=="Paul")"solved the problem for me.