-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
I was trying to use the WalkTree method, but it was getting an error: propertyValue.Value is not defined.
I already fixed it. I just built a new method to retrive the value from a BinaryExpression:
private static void WalkTree(BinaryExpression body, ExpressionType linkingType, ref List queryProperties)
{
if (body.NodeType != ExpressionType.AndAlso &&
body.NodeType != ExpressionType.OrElse)
{
string propertyName = GetPropertyName(body);
dynamic propertyValue = GetValue(body);
string opr = GetOperator(body.NodeType);
string link = GetOperator(linkingType);
queryProperties.Add(new QueryParameter(link, propertyName, propertyValue, opr));
}
else
{
WalkTree((BinaryExpression)body.Left, body.NodeType, ref queryProperties);
WalkTree((BinaryExpression)body.Right, body.NodeType, ref queryProperties);
}
}
private static object GetValue(BinaryExpression func)
{
return Expression.Lambda(func.Right).Compile().DynamicInvoke();
}
Btw, very nice implementation 👍
ismailtutumluer and tannguyent
Metadata
Metadata
Assignees
Labels
No labels