public Expression ArithmeticUnaryExpression(ArithmeticUnaryExpression expression) { var result = expression.Expression.Visit(this); var literal = result as LiteralExpression; if (literal != null) { return(ResolveArithmeticUnaryLiteral(expression, literal)); } return(new ArithmeticUnaryExpression(Operator.Negative, result)); }
public override IProjection ArithmeticUnaryExpression(ArithmeticUnaryExpression expression) { var projection = CreateProjection(expression.Expression); switch (expression.Operator) { case Operator.Negative: return(new ArithmeticOperatorProjection( "-", DefaultArithmeticReturnType, Projections.Constant(0), projection )); default: throw new NotSupportedException(); } }
private Expression ResolveArithmeticUnaryLiteral(ArithmeticUnaryExpression expression, LiteralExpression literal) { if (expression.Operator != Operator.Negative) { throw new NotSupportedException(); } object value = literal.Value; switch (literal.LiteralType) { case LiteralType.Decimal: value = -((decimal)value); break; case LiteralType.Double: value = -((double)value); break; case LiteralType.Duration: value = -((XmlTimeSpan)value); break; case LiteralType.Int: value = -((int)value); break; case LiteralType.Long: value = -((long)value); break; case LiteralType.Single: value = -((float)value); break; default: throw new ODataException(String.Format( ErrorMessages.Expression_CannotNegate, literal.LiteralType )); } return(new LiteralExpression(value, literal.LiteralType)); }
public virtual T ArithmeticUnaryExpression(ArithmeticUnaryExpression expression) { throw new QueryNotSupportException(); }
public Expression ArithmeticUnaryExpression(ArithmeticUnaryExpression expression) { return(new ArithmeticUnaryExpression(expression.Operator, expression.Expression.Visit(this))); }