src/Shared/EntityFramework/Core/Query/PlanCompiler/Predicate.cs
// <summary>
// Does this predicate preserve nulls on the specified columns of the table?
// If any of the columns participates in a comparison predicate, or in a
// not-null predicate, then, nulls are not preserved
// </summary>
// <param name="simplePredNode"> the "simple" predicate node </param>
// <param name="tableColumns"> list of table columns </param>
// <returns> true, if nulls are preserved </returns>
Does this predicate preserve nulls on the specified columns of the table.
If any of the columns participates in a comparison predicate, or in a
not-null predicate, then, nulls are not preserved
Does this predicate preserve nulls on the specified columns of the table . If any of the columns participates in a comparison predicate or in a not - null predicate then nulls are not preserved
private static bool PreservesNulls(Node simplePredNode, VarVec tableColumns)
        {
            VarRefOp varRefOp;
            switch (simplePredNode.Op.OpType)
            {
                case OpType.EQ:
                case OpType.NE:
                case OpType.GT:
                case OpType.GE:
                case OpType.LT:
                case OpType.LE:
                    varRefOp = simplePredNode.Child0.Op as VarRefOp;
                    if (varRefOp != null
                        && tableColumns.IsSet(varRefOp.Var))
                    {
                        return false;
                    }
                    varRefOp = simplePredNode.Child1.Op as VarRefOp;
                    if (varRefOp != null
                        && tableColumns.IsSet(varRefOp.Var))
                    {
                        return false;
                    }
                    return true;
                case OpType.Not:
                    if (simplePredNode.Child0.Op.OpType
                        != OpType.IsNull)
                    {
                        return true;
                    }
                    varRefOp = simplePredNode.Child0.Child0.Op as VarRefOp;
                    return (varRefOp == null || !tableColumns.IsSet(varRefOp.Var));
                case OpType.Like:
                    var constantOp = simplePredNode.Child1.Op as ConstantBaseOp;
                    if (constantOp == null
                        || (constantOp.OpType == OpType.Null))
                    {
                        return true;
                    }
                    varRefOp = simplePredNode.Child0.Op as VarRefOp;
                    if (varRefOp != null
                        && tableColumns.IsSet(varRefOp.Var))
                    {
                        return false;
                    }
                    return true;
                default:
                    return true;
            }
        }
private static bool PreservesNulls ( Node simplePredNode , VarVec tableColumns ) { VarRefOp varRefOp ; switch ( simplePredNode . Op . OpType ) { case OpType . EQ : case OpType . NE : case OpType . GT : case OpType . GE : case OpType . LT : case OpType . LE : varRefOp = simplePredNode . Child0 . Op as VarRefOp ; if ( varRefOp != null && tableColumns . IsSet ( varRefOp . Var ) ) { return false ; } varRefOp = simplePredNode . Child1 . Op as VarRefOp ; if ( varRefOp != null && tableColumns . IsSet ( varRefOp . Var ) ) { return false ; } return true ; case OpType . Not : if ( simplePredNode . Child0 . Op . OpType != OpType . IsNull ) { return true ; } varRefOp = simplePredNode . Child0 . Child0 . Op as VarRefOp ; return ( varRefOp == null || ! tableColumns . IsSet ( varRefOp . Var ) ) ; case OpType . Like : var constantOp = simplePredNode . Child1 . Op as ConstantBaseOp ; if ( constantOp == null || ( constantOp . OpType == OpType . Null ) ) { return true ; } varRefOp = simplePredNode . Child0 . Op as VarRefOp ; if ( varRefOp != null && tableColumns . IsSet ( varRefOp . Var ) ) { return false ; } return true ; default : return true ; } }
Does this predicate preserve nulls on the specified columns of the table?
Does this predicate preserve nulls on the specified columns of the table?
// If the predicate is "column LIKE constant ...", then the // predicate does not preserve nulls
true, if nulls are preserved
true if nulls are preserved
simplePredNode
Node
the "simple" predicate node
the " simple " predicate node
tableColumns
VarVec
list of table columns
list of table columns