System.Linq.Dynamic.Core parsing error

dynamic-linq

Question

I have a simple class with one int property called Int:

public class TestObject
    {
        public int Int { get; set; }
    }

and wherePredicate "Int >= 90"

When I trying to use it with a IQueryable.Where(wherePredicate) the error occurs: System.Linq.Dynamic.Core.Exceptions.ParseException: '.' or '(' or string literal expected

When I change wherePredicate to "It.Int >= 90" - works as expected.

1
0
11/15/2017 6:34:51 PM

Accepted Answer

Int is a reserved key-word.

Use a different Property name:

void Main()
{
    var l = new List<TestObject>();
    var q = l.AsQueryable();
    var result = q.Where("X >= 90");

    result.Dump(); // LINQPad
}

public class TestObject
{
    public int X { get; set; }
}
1
1/13/2018 11:26:56 AM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow