/// <inheritdoc/> public override bool Equals(Object ob) { Operator oob = (Operator)ob; return(op.Equals(oob.op) && subType == oob.subType); }
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["<>"]; }
/// <summary> /// Returns the inverse operator of this operator. /// </summary> /// <remarks> /// For example, = becomes <c><></c>, <c>></c> becomes /// <c><=</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 + "'"); }