Skip to content

Error when trying to access an object declared on another lambda #173

@VAdri

Description

@VAdri

Trying to parse a dynamic linq expression with multiple lambdas, when accessing an object declared on a parent lambda, throws an error:

context.Companies.Where("Employees.Any(e => e.Salary < it.MinimumSalary)");
System.Linq.Dynamic.Core.Exceptions.ParseException : No property or field 'MinimumSalary' exists in type 'Employee'

The parser ignores the identifiers (e and it) and uses automatically the last lambda that was declared, which leads to an error when trying to access the Company object inside the Employee lambda.

However, this behavior works as expected on a regular linq expression:

context.Companies.Where(c => c.Employees.Any(e => e.Salary < c.MinimumSalary));

Metadata

Metadata

Assignees

No one assigned

    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