Esempio n. 1
0
        /// <summary>
        /// Builds the specified filter node.
        /// </summary>
        /// <param name="filterNode">The filter node.</param>
        /// <param name="appendWhere">if set to <c>true</c> [append where].</param>
        public void Build(DbFilterGroup filterNode, bool appendWhere)
        {
            if (filterNode.Nodes.Count > 0)
            {
                if (appendWhere)
                {
                    sb.Append(" WHERE ");
                }

                build(filterNode);
            }
        }
Esempio n. 2
0
        private void build(DbFilterNode filterNode)
        {
            DbFilterGroup filterGroup = filterNode as DbFilterGroup;

            if (filterGroup != null)
            {
                string expression = (filterNode is DbAndFilterGroup) ? " AND " : " OR ";

                sb.Append('(');
                int count = filterGroup.Nodes.Count;
                for (int i = 0; i < count; i++)
                {
                    var node = filterGroup.Nodes[i];
                    build(node);

                    if (i < count - 1)
                    {
                        sb.Append(expression);
                    }
                }
                sb.Append(')');
            }
            else
            {
                DbFilterExpression exp = (DbFilterExpression)filterNode;
                sb.Append(exp.ToString(accessor, args.Count));
                exp.AddParameters(args);
            }

            /*sb.Append(filterNode[0].ToString(gateway.Accessor, 0));
             * filterNode[0].AddParameters(args);
             *
             * for (int i = 1; i < count; i++)
             * {
             *  sb.Append(" AND ");
             *  sb.Append(filterNode[i].ToString(gateway.Accessor, i));
             *  filterNode[i].AddParameters(args);
             * }*/
        }