public static bool Match(Operator op, ComparableComparator comparator, IComparable leftValue, Expression rightExpression, long rightExpressionRow) { switch (op) { case Operator.IsIn: case Operator.NotIn: { long rightRowCount = rightExpression.RowCount(); for (long expRow = 0; expRow != rightRowCount; ++expRow) { var rightValue = rightExpression.GetComparableValue(expRow); if (Compare(comparator, leftValue, rightValue) == 0) { return(op == Operator.IsIn); } } return(op == Operator.NotIn); } default: { var rightValue = rightExpression.GetComparableValue(rightExpressionRow); return(Match(op, comparator(leftValue, rightValue))); } } }
public static int Compare(ComparableComparator comparator, IComparable leftValue, IComparable rightValue) { try { return(comparator(leftValue, rightValue)); } catch (Exception e) { throw new Exception("Failed to compare values '" + (leftValue == null ? "null" : leftValue.ToString()) + "' and '" + (rightValue == null ? "null" : rightValue.ToString()) + "'. " + e.Message); } }
public static bool Match(Operator op, ComparableComparator comparator, IComparable leftValue, IComparable rightValue) { return(Match(op, Compare(comparator, leftValue, rightValue))); }