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

Possibility to parse an Expression<T, bool> to a valid expression string #133

Closed
frankiDotNet opened this issue Jan 4, 2018 · 2 comments
Assignees

Comments

@frankiDotNet
Copy link

frankiDotNet commented Jan 4, 2018

Hello,

is it possible to parse into the other direction?
Let's say I have an expression like:

public class Person
{
  public String Name { get; set; }
  public String FirstName { get; set; }
  public DateTime Birthday { get; set; }
}

Expression<Func<Person, bool>> filterExpression= x => x.Birthday > new DateTime(2001, 1, 1);

I would like to have something like this as result:

"x => x.Birthday > '2007-08-31'"

@StefH StefH self-assigned this Jan 4, 2018
@StefH
Copy link
Collaborator

StefH commented Jan 4, 2018

Just to a .ToString() ?

Expression<Func<Car, bool>> filterExpression = x => x.Key > 10;
string s = filterExpression.ToString(); // "x => (x.Key > 10)"

@StefH StefH closed this as completed Jan 4, 2018
@frankiDotNet
Copy link
Author

Yeah, this is ok with constant variables, but if you do it with the above expression that contains a DateTime object, the result isn't the expected.

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