Beispiel #1
0
        /// <inheritdoc/>
        public override bool Equals(Object ob)
        {
            Operator oob = (Operator)ob;

            return(op.Equals(oob.op) && subType == oob.subType);
        }
Beispiel #2
0
        static Operator()
        {
            // Populate the static ANY and ALL mapping
            AnyMap.Add("=", new AnyOperator("="));
            AnyMap.Add("<>", new AnyOperator("<>"));
            AnyMap.Add(">", new AnyOperator(">"));
            AnyMap.Add(">=", new AnyOperator(">="));
            AnyMap.Add("<", new AnyOperator("<"));
            AnyMap.Add("<=", new AnyOperator("<="));

            AllMap.Add("=", new AllOperator("="));
            AllMap.Add("<>", new AllOperator("<>"));
            AllMap.Add(">", new AllOperator(">"));
            AllMap.Add(">=", new AllOperator(">="));
            AllMap.Add("<", new AllOperator("<"));
            AllMap.Add("<=", new AllOperator("<="));

            // The IN and NOT IN operator are '= ANY' and '<> ALL' respectively.
            In = AnyMap["="];
            NotIn = AllMap["<>"];
        }
Beispiel #3
0
        /// <summary>
        /// Returns the inverse operator of this operator.
        /// </summary>
        /// <remarks>
        /// For example, = becomes <c>&lt;&gt;</c>, <c>&gt;</c> becomes
        /// <c>&lt;=</c>, <c>AND</c> becomes <c>OR</c>.
        /// </remarks>
        public Operator Inverse()
        {
            if (IsSubQuery)
            {
                OperatorSubType invType;
                if (IsSubQueryForm(OperatorSubType.Any))
                {
                    invType = OperatorSubType.All;
                }
                else if (IsSubQueryForm(OperatorSubType.All))
                {
                    invType = OperatorSubType.Any;
                }
                else
                {
                    throw new Exception("Can not handle sub-query form.");
                }

                Operator invOp = Get(op).Inverse();

                return(invOp.GetSubQueryForm(invType));
            }
            if (Equals(Equal))
            {
                return(NotEqual);
            }
            if (Equals(NotEqual))
            {
                return(Equal);
            }
            if (Equals(Greater))
            {
                return(LesserEqual);
            }
            if (Equals(Lesser))
            {
                return(GreaterEqual);
            }
            if (Equals(GreaterEqual))
            {
                return(Lesser);
            }
            if (Equals(LesserEqual))
            {
                return(Greater);
            }
            if (Equals(And))
            {
                return(Or);
            }
            if (Equals(Or))
            {
                return(And);
            }
            if (Equals(Like))
            {
                return(NotLike);
            }
            if (Equals(NotLike))
            {
                return(Like);
            }
            if (Equals(Is))
            {
                return(IsNot);
            }
            if (Equals(IsNot))
            {
                return(Is);
            }

            throw new ApplicationException("Can't inverse operator '" + op + "'");
        }