/// <summary> /// Write the unary token as URI part to this builder. /// </summary> /// <param name="unary">To write as URI part.</param> protected virtual void WriteUnary(UnaryOperatorQueryToken unary) { ExceptionUtils.CheckArgumentNotNull(unary, "unary"); switch (unary.OperatorKind) { case UnaryOperatorKind.Negate: this.builder.Append(ExpressionConstants.SymbolNegate); break; case UnaryOperatorKind.Not: this.builder.Append(ExpressionConstants.KeywordNot); this.builder.Append(ExpressionConstants.SymbolEscapedSpace); break; default: throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataUriBuilder_WriteUnary_UnreachableCodePath)); } this.WriteQuery(unary.Operand); }
/// <summary> /// Binds a unary operator token. /// </summary> /// <param name="unaryOperatorToken">The unary operator token to bind.</param> /// <returns>The bound unary operator token.</returns> protected virtual QueryNode BindUnaryOperator(UnaryOperatorQueryToken unaryOperatorToken) { ExceptionUtils.CheckArgumentNotNull(unaryOperatorToken, "unaryOperatorToken"); SingleValueQueryNode operand = this.Bind(unaryOperatorToken.Operand) as SingleValueQueryNode; if (operand == null) { throw new ODataException(Strings.MetadataBinder_UnaryOperatorOperandNotSingleValue(unaryOperatorToken.OperatorKind.ToString())); } IEdmTypeReference typeReference = operand.TypeReference; if (!TypePromotionUtils.PromoteOperandType(unaryOperatorToken.OperatorKind, ref typeReference)) { string typeName = operand.TypeReference == null ? "<null>" : operand.TypeReference.ODataFullName(); throw new ODataException(Strings.MetadataBinder_IncompatibleOperandError(typeName, unaryOperatorToken.OperatorKind)); } if (typeReference != null) { operand = ConvertToType(operand, typeReference); } return new UnaryOperatorQueryNode() { OperatorKind = unaryOperatorToken.OperatorKind, Operand = operand }; }