예제 #1
0
        /// <summary>
        /// Converts the criteria to string.
        /// </summary>
        /// <param name="sb">The string builder.</param>
        /// <param name="query">The target query to add params to.</param>
        public override void ToString(StringBuilder sb, IQueryWithParams query)
        {
            switch (op)
            {
            case CriteriaOperator.Paren:
                sb.Append('(');
                operand.ToString(sb, query);
                sb.Append(')');
                break;

            case CriteriaOperator.Not:
                sb.Append("NOT (");
                operand.ToString(sb, query);
                sb.Append(')');
                break;

            case CriteriaOperator.IsNull:
                operand.ToString(sb, query);
                sb.Append(" IS NULL");
                break;

            case CriteriaOperator.IsNotNull:
                operand.ToString(sb, query);
                sb.Append(" IS NOT NULL");
                break;

            case CriteriaOperator.Exists:
                sb.Append("EXISTS (");
                operand.ToString(sb, query);
                sb.Append(')');
                break;
            }
        }
예제 #2
0
 /// <summary>
 /// Converts the criteria to string in a string builder,
 /// while adding its params to the target query.
 /// </summary>
 /// <param name="sb">The string builder.</param>
 /// <param name="query">The target query.</param>
 public override void ToString(StringBuilder sb, IQueryWithParams query)
 {
     if (op == CriteriaOperator.Like ||
         op == CriteriaOperator.NotLike)
     {
         if (query.Dialect.IsLikeCaseSensitive &&
             right is ValueCriteria valueCriteria &&
             valueCriteria.Value is string)
         {
             sb.Append("UPPER(");
             left.ToString(sb, query);
             sb.Append(op == CriteriaOperator.Like ? ") LIKE UPPER(" : ") NOT LIKE UPPER(");
             right.ToString(sb, query);
             sb.Append(")");
         }
         else
         {
             left.ToString(sb, query);
             sb.Append(op == CriteriaOperator.Like ? " LIKE " : " NOT LIKE ");
             right.ToString(sb, query);
         }
     }