コード例 #1
0
        // this for now, but a expression tree for parsing boolean logic would probably be the way to do this.
        // only handles the case of one comparison... i.e. column = something
        private bool processWhere(IntSchRow row, List <string> whereClause)
        {
            string conditionOnColumn = whereClause[0];
            string conditionOperator = whereClause[1];
            object givenConditionObj = whereClause[2];

            IntSchValue storedValue = row.GetValueInColumn(conditionOnColumn);
            // make a IntSchValue object out of the user given condition that can be used for comparison to the stored value
            IntSchValue givenCondition = new IntSchValue(givenConditionObj, columns[conditionOnColumn].DataType);

            int comparisonResult = storedValue.CompareTo(givenCondition);

            switch (conditionOperator)
            {
            case ">": return(comparisonResult < 0);    // value > condition

            case ">=": return(comparisonResult <= 0);  // value >= condition

            case "<": return(comparisonResult > 0);    // value < condition

            case "<=": return(comparisonResult >= 0);  // value <= condition

            case "=": return(comparisonResult == 0);   // value == condition

            default: throw new Exception("Unsupported condition operator");
            }
        }