System.Linq.Dynamic.Core解析错误

时间:2017-11-15 18:34:52

标签: dynamic-linq

我有一个带有一个名为Int:

的int属性的简单类
public class TestObject
    {
        public int Int { get; set; }
    }

和wherePredicate" Int> = 90"

当我尝试将它与IQueryable.Where(wherePredicate)一起使用时,会发生错误:System.Linq.Dynamic.Core.Exceptions.ParseException:'。'或'('或字符串文字预期

当我将wherePredicate更改为" It.Int> = 90" - 按预期工作。

1 个答案:

答案 0 :(得分:1)

Int是保留的关键字。

使用其他属性名称:

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; }
}
相关问题