Пример #1
0
 private static bool ProcessNotOverConstantPredicate(
     RuleProcessingContext context,
     System.Data.Entity.Core.Query.InternalTrees.Node node,
     out System.Data.Entity.Core.Query.InternalTrees.Node newNode)
 {
     return(ScalarOpRules.ProcessLogOpOverConstant(context, node, node.Child0, (System.Data.Entity.Core.Query.InternalTrees.Node)null, out newNode));
 }
Пример #2
0
        private static bool ProcessSimplifyCase(
            RuleProcessingContext context,
            System.Data.Entity.Core.Query.InternalTrees.Node caseOpNode,
            out System.Data.Entity.Core.Query.InternalTrees.Node newNode)
        {
            CaseOp op = (CaseOp)caseOpNode.Op;

            newNode = caseOpNode;
            return(ScalarOpRules.ProcessSimplifyCase_Collapse(caseOpNode, out newNode) || ScalarOpRules.ProcessSimplifyCase_EliminateWhenClauses(context, op, caseOpNode, out newNode));
        }
Пример #3
0
        private static bool ProcessLikeOverConstant(
            RuleProcessingContext context,
            System.Data.Entity.Core.Query.InternalTrees.Node n,
            out System.Data.Entity.Core.Query.InternalTrees.Node newNode)
        {
            newNode = n;
            InternalConstantOp op1  = (InternalConstantOp)n.Child1.Op;
            InternalConstantOp op2  = (InternalConstantOp)n.Child0.Op;
            string             str1 = (string)op2.Value;
            string             str2 = (string)op1.Value;
            bool?nullable           = ScalarOpRules.MatchesPattern((string)op2.Value, (string)op1.Value);

            if (!nullable.HasValue)
            {
                return(false);
            }
            ConstantPredicateOp constantPredicateOp = context.Command.CreateConstantPredicateOp(nullable.Value);

            newNode = context.Command.CreateNode((Op)constantPredicateOp);
            return(true);
        }
Пример #4
0
        private static bool ProcessIsNullOverAnything(
            RuleProcessingContext context,
            System.Data.Entity.Core.Query.InternalTrees.Node isNullNode,
            out System.Data.Entity.Core.Query.InternalTrees.Node newNode)
        {
            Command command = context.Command;

            switch (isNullNode.Child0.Op.OpType)
            {
            case OpType.Cast:
                newNode = command.CreateNode((Op)command.CreateConditionalOp(OpType.IsNull), isNullNode.Child0.Child0);
                break;

            case OpType.Function:
                EdmFunction function = ((FunctionOp)isNullNode.Child0.Op).Function;
                newNode = ScalarOpRules.PreservesNulls(function) ? command.CreateNode((Op)command.CreateConditionalOp(OpType.IsNull), isNullNode.Child0.Child0) : isNullNode;
                break;

            default:
                newNode = isNullNode;
                break;
            }
            switch (isNullNode.Child0.Op.OpType)
            {
            case OpType.Constant:
            case OpType.InternalConstant:
            case OpType.NullSentinel:
                return(ScalarOpRules.ProcessIsNullOverConstant(context, newNode, out newNode));

            case OpType.Null:
                return(ScalarOpRules.ProcessIsNullOverNull(context, newNode, out newNode));

            case OpType.VarRef:
                return(ScalarOpRules.ProcessIsNullOverVarRef(context, newNode, out newNode));

            default:
                return(!object.ReferenceEquals((object)isNullNode, (object)newNode));
            }
        }