Open
Description
Hello, When I use execute against the following expression string on the expandoObject it works nicely, returns bool (true).
However when I compile the expression and try to invoke the Func<ExpandObject,bool> it throws with the exception below.
Would be grateful to know if compile and invoke would be expected to work in this scenario, considering Execute does.
Many thanks in advance. (example against .net 6.0)
dynamic input = new ExpandoObject();
input.User = new {
Addresses = new[]{
new{
Type = "Shipping",
Line1 = "York St"
},
new{
Type = "Billing",
Line1 = "Fleet St"
}
}
};
var exprString1 = "User.Addresses.FirstOrDefault(a => a.Type == \"Shipping\")?.Line1 == \"York St\"";
/* this works very nicely - returns true */
var execWorks = Eval.Execute<bool>(exprString1, input);
/* this compiles without error but invocation fails */
Func<ExpandoObject,bool> compiled = Eval.Compile<Func<ExpandoObject,bool>>(exprString1);
var result = compiled(input);
exception thrown
System.Exception
HResult=0x80131500
Message=Oops! A parameter still have the type 'SyntaxNode'
Source=Z.Expressions.Eval
StackTrace:
at .DynamicMethod(Object obj, Boolean isExtensionMethod, Object betterMember, String name, Object[] parameters, List`1 parameterExpressionInfos, List`1 extensionMethodRegister)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
Metadata
Metadata
Assignees
Labels
No labels