added query convert strategy.

This commit is contained in:
David
2018-02-12 03:30:55 -06:00
parent 8e88e13861
commit b1db7a3604
5 changed files with 47 additions and 17 deletions
@@ -80,5 +80,16 @@ namespace PoweredSoft.DynamicLinq.Helpers
object convertedValue = TypeHelpers.ConvertFrom(memberType, value);
return Expression.Constant(convertedValue);
}
public static ConstantExpression ResolveConstant(Expression member, object value, QueryConvertStrategy convertStrategy)
{
if (convertStrategy == QueryConvertStrategy.LeaveAsIs)
return Expression.Constant(value);
if (convertStrategy == QueryConvertStrategy.ConvertConstantToComparedPropertyOrField)
return QueryableHelpers.GetConstantSameAsLeftOperator(member, value);
throw new NotSupportedException($"{convertStrategy} supplied is not recognized");
}
}
}