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

ReferenceNotEqual() public static method

Creates a BinaryExpression that represents a reference inequality comparison.
public static ReferenceNotEqual ( Expression left, Expression right ) : BinaryExpression
left Expression An to set the property equal to.
right Expression An to set the property equal to.
return BinaryExpression
        public static BinaryExpression ReferenceNotEqual(Expression left, Expression right)
        {
            RequiresCanRead(left, nameof(left));
            RequiresCanRead(right, nameof(right));
            if (TypeUtils.HasReferenceEquality(left.Type, right.Type))
            {
                return new LogicalBinaryExpression(ExpressionType.NotEqual, left, right);
            }
            throw Error.ReferenceEqualityNotDefined(left.Type, right.Type);
        }

Usage Example

Ejemplo n.º 1
0
        public void ReferenceNotEquals()
        {
            var expected =
                LinqExpression.ReferenceNotEqual(
                    LinqExpression.Parameter(
                        typeof(object)),
                    LinqExpression.Parameter(
                        typeof(object)));

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

:s
    a :ReferenceNotEqual ;
    :binaryLeft [
        :parameterType [
            :typeName ""System.Object"" ;
        ]
    ] ;
    :binaryRight [
        :parameterType [
            :typeName ""System.Object"" ;
        ] ;
    ] ;
.
";

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