Open RonAmihai opened 5 months ago
Currently, as a temporary solution (until implementing proper dynamic LINQ support), I've solved that using LINQ extension methods for object
.
Then, by using the extensions below, one can define the interpreter as follows to enable dynamic LINQ functionality:
var interpreter = new Interpreter(InterpreterOptions.LateBindObject | InterpreterOptions.LambdaExpressions)
.Reference(typeof(DynamicLinqExtensions));
Notes:
LateBindObject
is required for nested dynamic fields support, not for the LINQ functionality.Cast
/ OfType
extensions (they are not mandatory for basic functionality since every operation performs cast to IEnumerable<object?>
internally).ThenBy
/ ThenByDescending
extensions, they are not mandatory. I've added them to avoid needing an additional typeof(Enumerable)
interpreter reference.data.nested.list.Where(...).ToHashSet().SetEquals(new T[] { ... } )
will require adding .AsEnumerable()
to the SetEquals
method parameter initialization (SetEquals
in that example is an instance method, not an extension method, and we cannot re-define it's behavior)Implementation:
LINQ extensions within expressions do not work when applied to properties of
ExpandoObject
. (For comparison - ExpressionEvaluator does support that with OptionInstanceMethodsCallActive)Given the following code:
The following exception is thrown: