ToSql() public method

public ToSql ( ) : string
return string
Beispiel #1
0
        public string ToSql(Operator op, QueryValue qv)
        {
            string value = qv.ToSql(op) ?? String.Empty;

            if (op == null)
            {
                op = qv.OperatorSet.First;
            }

            StringBuilder sb = new StringBuilder();

            if (no_custom_format)
            {
                string column_with_key = Column;
                if (qv is StringQueryValue && !(column_lowered || qv is ExactStringQueryValue))
                {
                    column_with_key = String.Format("HYENA_SEARCH_KEY({0})", Column);
                }
                sb.AppendFormat("{0} {1}", column_with_key, String.Format(op.SqlFormat, value));

                if (op.IsNot)
                {
                    return(String.Format("({0} OR {1} IS NULL)", sb.ToString(), Column));
                }
                else
                {
                    return(String.Format("({0} AND {1} IS NOT NULL)", sb.ToString(), Column));
                }
            }
            else
            {
                sb.AppendFormat(
                    Column, String.Format(op.SqlFormat, value),
                    value, op.IsNot ? "NOT" : null
                    );
            }

            return(sb.ToString());
        }
Beispiel #2
0
        public string ToSql (Operator op, QueryValue qv)
        {
            string value = qv.ToSql (op) ?? String.Empty;

            if (op == null) op = qv.OperatorSet.First;

            StringBuilder sb = new StringBuilder ();

            if (no_custom_format) {
                string column_with_key = Column;
                if (qv is StringQueryValue && !(column_lowered || qv is ExactStringQueryValue)) {
                    column_with_key = String.Format ("HYENA_SEARCH_KEY({0})", Column);
                }
                sb.AppendFormat ("{0} {1}", column_with_key, String.Format (op.SqlFormat, value));

                if (op.IsNot) {
                    return String.Format ("({0} IS NULL OR {1})", Column, sb.ToString ());
                } else {
                    return String.Format ("({0} IS NOT NULL AND {1})", Column, sb.ToString ());
                }
            } else {
                sb.AppendFormat (
                    Column, String.Format (op.SqlFormat, value),
                    value, op.IsNot ? "NOT" : null
                );
            }

            return sb.ToString ();
        }