error parsing dynamic link query using Microsoft Json Rules engine

50 Views Asked by At

Using Microsoft Json Rules engine.

The following rule expressions parse without an issue:

  1. "Names[0].PersonName.FirstName=="Paul""
  2. Names.Any()

but 3. throws the following parse exception

  1. "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.

1

There are 1 best solutions below

0
pbull001 On

Dynamic Linq using a operator called "it" to refer to the current instance.a

Changing the expression to the following: "Names.Any(it.PersonName.FirstName=="Paul")" solved the problem for me.