-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Question: Support to build Expressions besides LambdaExpressions #170
Comments
Can you post a clear code example? |
I'm refering to the Parse method as it appears in your wiki which seems to have been removed: |
The Wiki is not really correct at some points, I've removed that part. Can't use use this class: |
This class exposes only methods that return LambdaExpressions (LambdaExpresion or Expression<Func<T,bool>> ) They all eventually do this: Expression.Lambda(parser.Parse(args)) The old version exposed the same methods without the lambda conversion returning "unbound" expressions, essentially ommiting the Expression.Lamda() and returning the result of parser.Parse() So basicly something like this (in DynamicExpressionParser - not sure all the overloads are needed I just copied all that didn't return a strongly typed lambda) public static Expression Parse([CanBeNull] ParsingConfig parsingConfig, bool createParameterCtor, [CanBeNull] Type resultType, [NotNull] string expression, params object[] values)
{
Check.NotEmpty(expression, nameof(expression));
var parser = new ExpressionParser(new ParameterExpression[0], expression, values, parsingConfig);
return parser.Parse(resultType, createParameterCtor);
}
public static Expression Parse([CanBeNull] ParsingConfig parsingConfig, bool createParameterCtor, [NotNull] ParameterExpression[] parameters, [CanBeNull] Type resultType, [NotNull] string expression, params object[] values)
{
Check.NotNull(parameters, nameof(parameters));
Check.HasNoNulls(parameters, nameof(parameters));
Check.NotEmpty(expression, nameof(expression));
var parser = new ExpressionParser(parameters, expression, values, parsingConfig);
return parser.Parse(resultType, createParameterCtor);
}
public static Expression Parse(bool createParameterCtor, [NotNull] Type itType, [CanBeNull] Type resultType, string expression, params object[] values)
{
Check.NotNull(itType, nameof(itType));
Check.NotEmpty(expression, nameof(expression));
return Parse(createParameterCtor, new[] { ParameterExpressionHelper.CreateParameterExpression(itType, string.Empty) }, resultType, expression, values);
}
public static Expression Parse([CanBeNull] ParsingConfig parsingConfig, [CanBeNull] Type resultType, [NotNull] string expression, params object[] values)
{
return Parse(parsingConfig, true, resultType, expression, values);
}
public static Expression Parse([CanBeNull] Type resultType, [NotNull] string expression, params object[] values)
{
Check.NotEmpty(expression, nameof(expression));
return Parse(null, true, resultType, expression, values);
}
public static Expression Parse([NotNull] Type itType, [CanBeNull] Type resultType, string expression, params object[] values)
{
return Parse(true, itType, resultType, expression, values);
}
public static Expression Parse([CanBeNull] ParsingConfig parsingConfig, [NotNull] Type itType, [CanBeNull] Type resultType, string expression, params object[] values)
{
return Parse(true, itType, resultType, expression, parsingConfig, values);
}
public static Expression Parse([CanBeNull] ParsingConfig parsingConfig, bool createParameterCtor, [NotNull] Type itType, [CanBeNull] Type resultType, string expression, params object[] values)
{
Check.NotNull(itType, nameof(itType));
Check.NotEmpty(expression, nameof(expression));
return Parse(parsingConfig, createParameterCtor, new[] { ParameterExpressionHelper.CreateParameterExpression(itType, string.Empty) }, resultType, expression, values);
}
public static Expression Parse([NotNull] ParameterExpression[] parameters, [CanBeNull] Type resultType, string expression, params object[] values)
{
return Parse(null, true, parameters, resultType, expression, values);
}
public static Expression Parse([CanBeNull] ParsingConfig parsingConfig, [NotNull] ParameterExpression[] parameters, [CanBeNull] Type resultType, string expression, params object[] values)
{
return Parse(parsingConfig, true, parameters, resultType, expression, values);
}
public static Expression Parse(bool createParameterCtor, [NotNull] ParameterExpression[] parameters, [CanBeNull] Type resultType, [NotNull] string expression, params object[] values)
{
return Parse(null, createParameterCtor, parameters, resultType, expression, values);
} |
So if the |
Yeah sure that would work great
Στις Δευ, 4 Ιουν 2018, 18:17 ο χρήστης Stef Heyenrath <
[email protected]> έγραψε:
… So if the ExpressionParser was public, this will solve your problem?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#170 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALMqQj3UDVhxeVNT7LHKnX1rb65nUa04ks5t5U-KgaJpZM4UXnZc>
.
|
New NuGet will be uploaded in some time. |
1.0.8.10 (make ExpressionParser public again) linked to issue #170
I'm trying to migrate an old project that had the original ms code embedded to using this library.
However this version has removed the Expression returning Parse methods and the parser class is internal so there is no way of using this other than building a lambda and replacing the input parameter with a visitor which is kind of costly.
For the record we are using this library to parse arbitrary mappings and build dynamic projections of tables so we need a source field expression
The text was updated successfully, but these errors were encountered: