This project is read-only.

Nested Any()..

May 4, 2016 at 6:38 PM
Hi:

I was trying to use an expression like this:
"prop1.col1.Any(it.col2.Any(it.Name.Contains(@0))) AND prop2 >= @1)"

and I got an error message stating pro2 doesnt exist in type of col1.

It looks like the scope of prop2 was interpreted incorrectly. It works fine if I switch sides like "prop2...... AND prop1.col1.Any(....)"

Has anyone had issues like this? Any suggestions/comments are much appreciated.

Thanks
May 25, 2016 at 6:42 PM
Edited May 25, 2016 at 6:43 PM
I added a unit-test for this question to (https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/test/System.Linq.Dynamic.Core.Tests/DynamicTests.cs#L32)

And it seems to work fine:
public void Any_Nested()
{
    const string search = "a";

    // Arrange
    var testList = User.GenerateSampleModels(10);
    var q = testList.AsQueryable();

    // Act
    var expected = q.Where(u => u.Roles.Any(r => r.Permissions.Any(p => p.Name.Contains(search))));
    var result = q.Where("Roles.Any(Permissions.Any(Name.Contains(@0)))", search);

    Assert.Equal(expected, result);
}
So please use this project + Nuget for verify your question:
https://www.nuget.org/packages/System.Linq.Dynamic.Core/
Jun 30, 2016 at 8:51 PM
Hi:

Sorry for the late reply and thanks a lot for your reply and the test project. But it seems the project is not available.
So my point is in addition to nested any, if I append another condition to filter by paramter like 'AND prop2 >= @1' I got the error.
Thank you again!

Cheers
Jun 30, 2016 at 10:21 PM