Skip to content

Dictionary parameter issue #397

@b0bi79

Description

@b0bi79

If pass Dictionary as a parameter for a lambda expression, then DynamicInvoke will return the first result each time. It looks like a cached result is returning.

        [Fact]
        public void EvalDictionaryParams2()
        {
            object CreateDicParameter(string name) => new Dictionary<string, object>
                {{"Name", new Dictionary<string, object> {{"FirstName", name }}}};

            var config = new ParsingConfig()
            {
                CustomTypeProvider = new DefaultDynamicLinqCustomTypeProvider()
            };
            var parType = new Dictionary<string, object>().GetType();
            var lambda = DynamicExpressionParser.ParseLambda(config, new [] {Expression.Parameter(parType, "item")}, typeof(object), "item.Name.FirstName").Compile();
            lambda.DynamicInvoke(CreateDicParameter("Julio")).Should().Be("Julio");
            lambda.DynamicInvoke(CreateDicParameter("John")).Should().Be("John");  // Failure. DynamicInvoke returns "Julio"
        }

Metadata

Metadata

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