System.Linq.Expressions.Expression.Negate C# (CSharp) Method

Negate() public static method

Creates a UnaryExpression that represents an arithmetic negation operation.
Thrown when is null. Thrown when the unary minus operator is not defined for .Type.
public static Negate ( Expression expression ) : UnaryExpression
expression Expression An to set the property equal to.
return UnaryExpression
        public static UnaryExpression Negate(Expression expression)
        {
            return Negate(expression, method: null);
        }

Same methods

Expression::Negate ( Expression expression, MethodInfo method ) : UnaryExpression

Usage Example

Ejemplo n.º 1
0
        public void Method()
        {
            var expected =
                LinqExpression.Negate(
                    LinqExpression.Default(
                        typeof(bool)),
                    typeof(SampleClass).GetMethod(nameof(SampleClass.StaticFunctionWithArgument)));

            var actual = $@"
@prefix : <http://example.com/> .
@prefix xt: <http://example.com/ExpressionTypes/> .

:s
    :unaryExpressionType xt:Negate ;
    :unaryOperand [
        :defaultType [
            :typeName ""System.Boolean"" ;
        ] ;
    ] ;
    :unaryMethod [
        :memberType [
            :typeName ""GraphEngine.Tests.SampleClass, GraphEngine.Tests"" ;
        ] ;
        :memberName ""StaticFunctionWithArgument"" ;
    ] ;
.
";

            ShouldBe(actual, expected);
        }
All Usage Examples Of System.Linq.Expressions.Expression::Negate
Expression