Skip to content

The execution result of DynamicExpressionParser.ParseLambda<JObject, bool> is incorrect. #906

@xiaoty9

Description

@xiaoty9
        Customer customer = Customers[0];


        JsonObject jsonObject = new JsonObject();
        jsonObject.Add("City", "Paris");
        jsonObject.Add("Column2", 1);

        string query = " City = \"Paris\"";
        JObject jObject = new JObject { ["City"] = "Paris", ["Column2"] = 1 };

        var config = new ParsingConfig
        {
            ResolveTypesBySimpleName = true,
            AllowNewToEvaluateAnyType = true
        };

        var expression = DynamicExpressionParser.ParseLambda<JObject, bool>(config, true, query);
        string s = expression.ToString();
        var del = expression.Compile();
        var result = del.Invoke(jObject);

        Check.That(result).IsEqualTo(true);

The correct running result result is true.
When this code is set as ParseLambda<Customer, bool>, the result after running is true.

But set to

ParseLambda<JObject, bool>
ParseLambda<JsonObject, bool>
ParseLambda<dynamic, bool>

After running this code, the result is false.

I wonder what's wrong?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions