Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Handle parameter query object before use
 /// </summary>
 /// <param name="parameterQuery">Parameter query</param>
 /// <param name="parameterQueryOption">Parameter query option</param>
 /// <returns>Return the newest query object</returns>
 internal static TQuery HandleParameterQueryBeforeUse <TQuery>(TQuery parameterQuery, QueryParameterOption parameterQueryOption) where TQuery : IQuery
 {
     if (parameterQuery == null)
     {
         return(parameterQuery);
     }
     if (EnableCopyParameterQueryObject)
     {
         parameterQuery = (TQuery)parameterQuery.DeepCopy();
     }
     if (parameterQueryOption != null)
     {
         if (!string.IsNullOrWhiteSpace(parameterQueryOption.QueryFieldName))
         {
             parameterQuery.ClearQueryFields();
             parameterQuery.AddQueryFields(parameterQueryOption.QueryFieldName);
         }
     }
     return(parameterQuery);
 }
Ejemplo n.º 3
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);
        }