예제 #1
0
 internal ColumnCondition(INumericCondition pLeft, Operator dbOperator, object pRight)
     : base(pLeft, dbOperator, pRight)
 {
     if (pLeft == null)
     {
         throw new NullReferenceException("pLeft cannot be null");
     }
     if (pRight == null)
     {
         throw new NullReferenceException("pRight cannot be null");
     }
 }
예제 #2
0
        string GetSideSql(DatabaseBase database, object cond, Parameters parameters, DbType?dbType)
        {
            if (cond is Condition)
            {
                return(GetConditionSql(database, (Condition)cond, parameters));
            }
            if (cond is ColumnBase)
            {
                return(GetColumnSql((ColumnBase)cond));
            }
            if (cond is QueryBuilderBase)
            {
                return("(" + GetSelectQuery(database, (QueryBuilderBase)cond, parameters) + ")");
            }
            if (!(cond is INumericCondition))
            {
                return(GetValue(database, cond, parameters, dbType));
            }
            INumericCondition numericCondition = (INumericCondition)cond;
            string            str;

            switch (numericCondition.Operator)
            {
            case NumericOperator.ADD:
                str = "+";
                break;

            case NumericOperator.SUBTRACT:
                str = "-";
                break;

            case NumericOperator.DIVIDE:
                str = "/";
                break;

            case NumericOperator.MULTIPLY:
                str = "*";
                break;

            case NumericOperator.MODULO:
                str = "%";
                break;

            default:
                throw new Exception("Unknown numeric operator : '" + numericCondition.Operator.ToString());
            }
            return(string.Format("({0}{1}{2})",
                                 GetSideSql(database, numericCondition.Left, parameters),
                                 str,
                                 GetSideSql(database, numericCondition.Right, parameters)));
        }