src/Shared/EntityFramework/Core/Mapping/ViewGeneration/Structures/NegatedConstant.cs
// <summary>
// Given a set of positive <paramref name="constants" /> generates a simplified negated constant Cql expression.
// Examples:
// - 7, NOT(7, NULL) means NOT(NULL)
// - 7, 8, NOT(7, 8, 9, 10) means NOT(9, 10)
// </summary>
Given a set of positive  generates a simplified negated constant Cql expression.
Given a set of positive generates a simplified negated constant Cql expression .
private void AsCql(
            Action trueLiteral, Action varIsNotNull, Action<Constant> varNotEqualsTo, IEnumerable<Constant> constants,
            MemberPath outputMember, bool skipIsNotNull)
        {
            var isNullable = outputMember.IsNullable;
            var negatedConstants = new Set<Constant>(Elements, EqualityComparer);
            foreach (var constant in constants)
            {
                if (constant.Equals(this))
                {
                    continue;
                }
                Debug.Assert(negatedConstants.Contains(constant), "Negated constant must contain all positive constants");
                negatedConstants.Remove(constant);
            }
            if (negatedConstants.Count == 0)
            {
                trueLiteral();
            }
            else
            {
                var hasNull = negatedConstants.Contains(Null);
                negatedConstants.Remove(Null);
                if (hasNull || (isNullable && !skipIsNotNull))
                {
                    varIsNotNull();
                }
                foreach (var constant in negatedConstants)
                {
                    varNotEqualsTo(constant);
                }
            }
        }
private void AsCql ( Action trueLiteral , Action varIsNotNull , Action < Constant > varNotEqualsTo , IEnumerable < Constant > constants , MemberPath outputMember , bool skipIsNotNull ) { var isNullable = outputMember . IsNullable ; var negatedConstants = new Set < Constant > ( Elements , EqualityComparer ) ; foreach ( var constant in constants ) { if ( constant . Equals ( this ) ) { continue ; } Debug . Assert ( negatedConstants . Contains ( constant ) , " " ) ; negatedConstants . Remove ( constant ) ; } if ( negatedConstants . Count == 0 ) { trueLiteral ( ) ; } else { var hasNull = negatedConstants . Contains ( Null ) ; negatedConstants . Remove ( Null ) ; if ( hasNull || ( isNullable && ! skipIsNotNull ) ) { varIsNotNull ( ) ; } foreach ( var constant in negatedConstants ) { varNotEqualsTo ( constant ) ; } } }
Given a set of positive  generates a simplified negated constant Cql expression.
Given a set of positive generates a simplified negated constant Cql expression .
// Remove all the constants from negated and then print "x <> C1 .. AND x <> C2 .. AND x <> C3 ..." // All constants cancel out - emit True. // We always add IS NOT NULL if the property is nullable (and we cannot skip IS NOT NULL). // Also, if the domain contains NOT NULL, we must add it.
trueLiteral
Action
varIsNotNull
Action
varNotEqualsTo
Action<Constant>
constants
IEnumerable<Constant>
outputMember
MemberPath
skipIsNotNull
bool