Пример #1
0
        public override string GetSqlFilter()
        {
            if (Selection.AllSelected)
            {
                return(null);
            }

            StringBuilder sb    = new StringBuilder("(");
            bool          first = true;

            //QueryListNode or = new QueryListNode (Keyword.Or);
            foreach (object o in GetSelectedObjects())
            {
                if (o != select_all_item)
                {
                    string     sql = null;
                    QueryValue qv  = QueryValue.CreateFromStringValue(o.ToString(), field);
                    //QueryListNode and = new QueryListNode (Keyword.And, or);
                    if (qv != null)
                    {
                        if (qv is IntegerQueryValue)
                        {
                            /*QueryTermNode term = new QueryTermNode ();
                             * term.Field = field;
                             * field.ToSql (IntegerQueryValue.GreaterThanEqual, qv);
                             * field.ToSql (IntegerQueryValue.GreaterThanEqual, qv);*/
                        }
                        else if (qv is StringQueryValue)
                        {
                            // TODO this might need fixing
                            //sql = field.ToSql (StringQueryValue.Equal, qv, true);
                            sql = field.ToSql(StringQueryValue.Equal, qv);
                        }
                    }
                    else
                    {
                        // TODO this might need fixing
                        //sql = field.ToSql (NullQueryValue.IsNullOrEmpty, NullQueryValue.Instance, true);
                        sql = field.ToSql(NullQueryValue.IsNullOrEmpty, NullQueryValue.Instance);
                    }

                    if (sql != null)
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            sb.Append(" OR ");
                        }
                        sb.Append(sql);
                    }
                }
            }
            sb.Append(")");
            return(first ? null : sb.ToString());
        }
Пример #2
0
        private void UpdateQueryTree(QueryNode query, string target)
        {
            if (query == null || String.IsNullOrEmpty(target))
            {
                return;
            }

            foreach (QueryTermNode node in query.GetTerms())
            {
                node.Value = QueryValue.CreateFromStringValue(target, node.Field);
            }
        }
Пример #3
0
        private QueryTermNode CreateNode(QueryField field, Operator op, string target)
        {
            QueryTermNode node = new QueryTermNode();

            if (field == null || op == null || String.IsNullOrEmpty(target))
            {
                return(node);
            }

            node.Field    = field;
            node.Operator = op;
            node.Value    = QueryValue.CreateFromStringValue(target, field);

            return(node);
        }