Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with parsing #120

Closed
stristan opened this issue Nov 15, 2017 · 2 comments
Closed

Error with parsing #120

stristan opened this issue Nov 15, 2017 · 2 comments

Comments

@stristan
Copy link

stristan commented Nov 15, 2017

Hello!
I'm trying to make a correct filter expression with no success:

public void LinqExpressionShouldBeSerialized()
{
    var filter = "Name==\"Name\" && Int >= 90";

    var objects = Enumerable.Range(1, 100).Select(i => new TestObject
    {
	Name = $"Name {i}",
	Int = i
    }).AsQueryable();

    var e = DynamicExpressionParser.ParseLambda(typeof(TestObject), filter);
    var filteredObjects = objects.Where(filter);
    Console.WriteLine(filteredObjects.Count());
}

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

The error message is "Unknown identifier 'Name'"

@StefH
Copy link
Collaborator

StefH commented Nov 15, 2017

1]
This code : var e = DynamicExpressionParser.ParseLambda(typeof(TestObject), filter);
use it like https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/test/System.Linq.Dynamic.Core.Tests/DynamicExpressionParserTests.cs#L108

2]
Int is reserved, use var filter = "Name == \"Name\" && X >= 90";

@StefH StefH closed this as completed Nov 15, 2017
@stristan
Copy link
Author

Thanks, it's worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants