public override string BuildListQuery(Guid treeNodeID)
        {
            StringBuilder sql = new StringBuilder();

            //--
            List<GetCustomClassificationTreeChildsResult> nodes = this.Provider.GetCustomClassificationTreeChilds(treeNodeID).ToList();

            WhereClause classificationWhere = WhereClause.Join(
                new List<WhereClause>()
                {
                    new CustomClassificationWhereClauseBuilder(nodes.Select(n => n.NodeID).Distinct().ToList()),
                    new ClassificationWhereClauseBuilder(nodes.Select(n => n.ClassificationTreeID).Distinct().ToList(), Provider)
                }, WhereClause.Operator.OR);
            //--

            List<WhereClause> whereList = SearchSource.Convert(this.SearchExpression);
            //whereList.Insert(0, classificationWhere);
            //whereList.Insert(0, customClassificationWhere);
            whereList.Insert(0, classificationWhere);
            string where = WhereClause.BuildExpression(/*classificationWhere, this.SearchExpression*/whereList);
            if (where.Length == 0) where = WhereClause.NULLResultWhereClause;

            //-collect from and join values-
            Aspect.Model.Query.FieldsSQLBuilder propertyQuery = new PropertyFieldsSQLBuilder(Columns);
            Aspect.Model.Query.FieldsSQLBuilder dictionaryQuery = new DictionaryFieldsSQLBuilder(UserFields, Provider);

            StringBuilder join = new StringBuilder();
            join.Append(propertyQuery.Join);
            join.Append(dictionaryQuery.Join);

            StringBuilder from = new StringBuilder();
            from.Append(propertyQuery.From);
            from.Append(dictionaryQuery.From);

            sql.AppendFormat(SqlTemplate,
                from.ToString(),
                join.ToString(),
                where,
                OrderExpression.OrderClause);
            return sql.ToString();
        }
Exemple #2
0
        public virtual string BuildEntityQuery(Guid ID)
        {
            StringBuilder sql = new StringBuilder();
            //-collect from and join values-
            Aspect.Model.Query.FieldsSQLBuilder propertyQuery = new PropertyFieldsSQLBuilder(Columns);
            Aspect.Model.Query.FieldsSQLBuilder dictionaryQuery = new DictionaryFieldsSQLBuilder(UserFields, Provider);

            StringBuilder join = new StringBuilder();
            join.Append(propertyQuery.Join);
            join.Append(dictionaryQuery.Join);

            StringBuilder from = new StringBuilder();
            from.Append(propertyQuery.From);
            from.Append(dictionaryQuery.From);
            //
            string where = WhereClause.BuildExpression(ProductProvider.ProductIDColumn, ID.ToString());
            sql.AppendFormat(this.SqlTemplate,
                from.ToString(),
                join.ToString(),
                where,
                string.Empty);
            return sql.ToString();
        }
Exemple #3
0
        public virtual string BuildListQuery(Guid treeNodeID)
        {
            StringBuilder sql = new StringBuilder();
            WhereClause classificationWhere = new ClassificationWhereClauseBuilder(treeNodeID, Provider);
            //--
            List<WhereClause> whereList = SearchSource.Convert(this.SearchExpression);
            whereList.Insert(0, classificationWhere);
            string where = WhereClause.BuildExpression(/*classificationWhere, this.SearchExpression*/ whereList);

            //-collect from and join values-
            Aspect.Model.Query.FieldsSQLBuilder propertyQuery = new PropertyFieldsSQLBuilder(Columns);
            Aspect.Model.Query.FieldsSQLBuilder dictionaryQuery = new DictionaryFieldsSQLBuilder(UserFields, Provider);

            StringBuilder join = new StringBuilder();
            join.Append(propertyQuery.Join);
            join.Append(dictionaryQuery.Join);

            StringBuilder from = new StringBuilder();
            from.Append(propertyQuery.From);
            from.Append(dictionaryQuery.From);

            //prevent order by not selected record
            if (!from.ToString().Contains(OrderExpression.Expression)) OrderExpression = new OrderExpression();

            sql.AppendFormat(SqlTemplate,
                from.ToString(),
                join.ToString(),
                where,
                OrderExpression.OrderClause);
            return sql.ToString();
        }