예제 #1
0
        internal static bool?CanBeNull(SqlExpression expr)
        {
            switch (expr.NodeType)
            {
            case SqlNodeType.ExprSet:
                SqlExprSet exprSet = (SqlExprSet)expr;
                return(CanBeNull(exprSet.Expressions));

            case SqlNodeType.SimpleCase:
                SqlSimpleCase sc = (SqlSimpleCase)expr;
                return(CanBeNull(sc.Whens.Select(w => w.Value)));

            case SqlNodeType.Column:
                SqlColumn col = (SqlColumn)expr;
                if (col.MetaMember != null)
                {
                    return(col.MetaMember.CanBeNull);
                }
                else if (col.Expression != null)
                {
                    return(CanBeNull(col.Expression));
                }
                return(null);     // Don't know.

            case SqlNodeType.ColumnRef:
                SqlColumnRef cref = (SqlColumnRef)expr;
                return(CanBeNull(cref.Column));

            case SqlNodeType.Value:
                return(((SqlValue)expr).Value == null);

            case SqlNodeType.New:
            case SqlNodeType.Multiset:
            case SqlNodeType.Grouping:
            case SqlNodeType.DiscriminatedType:
            case SqlNodeType.IsNotNull:     // IsNull\IsNotNull always return true or false and can never return NULL.
            case SqlNodeType.IsNull:
            case SqlNodeType.Exists:
                return(false);

            case SqlNodeType.Add:
            case SqlNodeType.Sub:
            case SqlNodeType.Mul:
            case SqlNodeType.Div:
            case SqlNodeType.Mod:
            case SqlNodeType.BitAnd:
            case SqlNodeType.BitOr:
            case SqlNodeType.BitXor:
            case SqlNodeType.Concat: {
                SqlBinary bop   = (SqlBinary)expr;
                bool?     left  = CanBeNull(bop.Left);
                bool?     right = CanBeNull(bop.Right);
                return((left != false) || (right != false));
            }

            case SqlNodeType.Negate:
            case SqlNodeType.BitNot: {
                SqlUnary uop = (SqlUnary)expr;
                return(CanBeNull(uop.Operand));
            }

            case SqlNodeType.Lift: {
                SqlLift lift = (SqlLift)expr;
                return(CanBeNull(lift.Expression));
            }

            case SqlNodeType.OuterJoinedValue:
                return(true);

            default:
                return(null);    // Don't know.
            }
        }
예제 #2
0
 internal virtual SqlExpression VisitLift(SqlLift lift)
 {
     lift.Expression = this.VisitExpression(lift.Expression);
     return(lift);
 }
 internal override SqlExpression VisitLift(SqlLift lift)
 {
     return(new SqlLift(lift.ClrType, this.VisitExpression(lift.Expression), lift.SourceExpression));
 }
 internal override SqlExpression VisitLift(SqlLift lift)
 {
     lift.Expression = base.VisitExpression(lift.Expression);
     return(lift);
 }
예제 #5
0
 internal override SqlExpression VisitLift(SqlLift lift) => new SqlLift(lift.ClrType, VisitExpression(lift.Expression), lift.SourceExpression);