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));
Trying to parse a dynamic linq expression with multiple lambdas, when accessing an object declared on a parent lambda, throws an error:
The parser ignores the identifiers (
eandit) and uses automatically the last lambda that was declared, which leads to an error when trying to access theCompanyobject inside theEmployeelambda.However, this behavior works as expected on a regular linq expression: