You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
The Execute method can work as we know the type of the Addresses (Even if we compile the method, we can still have access to the value of the parameter).
The Compile method currently doesn't work as we probably have no idea what is the current type. Since that's an ExpandoObject, the type could be anything.
I will assign my developer to look at what can be done here.
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)
exception thrown
The text was updated successfully, but these errors were encountered: