Exemplo n.º 1
0
        /// <summary>
        /// Add criteria query item handler
        /// </summary>
        /// <param name="originalQuery">Original query</param>
        /// <param name="queryItem">Parameter query item</param>
        /// <param name="parameterQueryOption">Parameter query option</param>
        static IQueryItem AddCriteriaQueryItemHandler(DefaultQuery originalQuery, IQueryItem queryItem, QueryParameterOption parameterQueryOption)
        {
            if (originalQuery == null || queryItem == null)
            {
                return(null);
            }
            Criteria criteria   = queryItem as Criteria;
            var      queryValue = criteria.Value as IQuery;

            if (queryValue != null)
            {
                if (queryValue.GetEntityType() == null)
                {
                    throw new EZNEWException("the IQuery object used for the subquery must set the property EntityType");
                }
                queryValue = HandleParameterQueryBeforeUse(queryValue, parameterQueryOption);
                criteria.SetValue(queryValue);
                originalQuery.subqueryCollection.Add(queryValue);
                originalQuery.SetHasSubQuery(true);
                originalQuery.SetHasJoin(originalQuery.HasJoin || queryValue.HasJoin);
                originalQuery.SetHasRecurveCriteria(originalQuery.HasRecurveCriteria || queryValue.HasRecurveCriteria);
            }
            else
            {
                bool             equalCriterial          = false;
                bool             verifyValueNull         = false;
                CriteriaOperator verifyValueNullOperator = CriteriaOperator.IsNull;
                switch (criteria.Operator)
                {
                case CriteriaOperator.Equal:
                    equalCriterial  = true;
                    verifyValueNull = true;
                    break;

                case CriteriaOperator.NotEqual:
                    verifyValueNull         = true;
                    verifyValueNullOperator = CriteriaOperator.NotNull;
                    break;

                case CriteriaOperator.In:
                    equalCriterial = true;
                    break;
                }
                if (criteria.GetCriteriaRealValue() == null && verifyValueNull)
                {
                    equalCriterial    = false;
                    criteria.Operator = verifyValueNullOperator;
                }
                if (equalCriterial)
                {
                    originalQuery.equalCriteriaCollection.Add(criteria);
                }
            }
            originalQuery.atomicConditionCount++;
            originalQuery.allConditionFieldNameCollection.Add(criteria.Name);
            return(criteria);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add queryInfo query item handler
        /// </summary>
        /// <param name="originalQuery">Original query</param>
        /// <param name="queryItem">Parameter query item</param>
        /// <param name="parameterQueryOption">Parameter query option</param>
        static IQueryItem AddQueryInfoQueryItemHandler(DefaultQuery originalQuery, IQueryItem queryItem, QueryParameterOption parameterQueryOption)
        {
            if (originalQuery == null || queryItem == null)
            {
                return(null);
            }
            DefaultQuery valueQuery = queryItem as DefaultQuery;

            valueQuery = HandleParameterQueryBeforeUse(valueQuery, parameterQueryOption);
            valueQuery.SetEntityType(originalQuery.entityType);
            originalQuery.SetHasSubQuery(originalQuery.HasSubquery || valueQuery.HasSubquery);
            originalQuery.SetHasJoin(originalQuery.HasJoin || valueQuery.HasJoin);
            originalQuery.SetHasRecurveCriteria(originalQuery.HasRecurveCriteria || valueQuery.HasRecurveCriteria);
            originalQuery.equalCriteriaCollection.AddRange(valueQuery.equalCriteriaCollection);
            originalQuery.atomicConditionCount += valueQuery.AtomicConditionCount;
            originalQuery.allConditionFieldNameCollection.AddRange(valueQuery.AllConditionFieldNames);
            originalQuery.alreadySetGlobalCondition |= valueQuery.alreadySetGlobalCondition;
            return(valueQuery);
        }