Exemple #1
0
        /// <summary>
        /// Get global condition
        /// </summary>
        /// <param name="conditionFilter">Condition filter</param>
        /// <returns>Return global condition</returns>
        internal static GlobalCondition GetGlobalCondition(GlobalConditionFilter conditionFilter)
        {
            if (conditionFilter == null)
            {
                throw new EZNEWException("GlobalConditionFilter is null");
            }
            if (conditionFilter.EntityType == null)
            {
                throw new EZNEWException("GlobalConditionFilter.EntityType is null");
            }
            if (conditionFilter.OriginalQuery == null)
            {
                conditionFilter.OriginalQuery = Create();
                conditionFilter.OriginalQuery.SetEntityType(conditionFilter.EntityType);
            }
            GlobalCondition globalCondition = null;

            if (!GetGlobalConditionProxys.IsNullOrEmpty() && conditionFilter.OriginalQuery.AllowSetGlobalCondition())
            {
                foreach (var globalConditionProxy in GetGlobalConditionProxys)
                {
                    var nowGlobalCondition = globalConditionProxy(conditionFilter);
                    if (nowGlobalCondition?.Value == null)
                    {
                        continue;
                    }
                    if (globalCondition == null)
                    {
                        globalCondition = nowGlobalCondition;
                    }
                    else
                    {
                        globalCondition.Value = globalCondition.Value.AddQueryItem(nowGlobalCondition.AppendMethod, nowGlobalCondition.Value);
                    }
                }
            }
            return(globalCondition);
        }
Exemple #2
0
        /// <summary>
        /// Get global condition
        /// </summary>
        /// <param name="conditionFilter">Condition filter</param>
        /// <returns>Return global condition</returns>
        internal static GlobalCondition GetGlobalCondition(GlobalConditionFilter conditionFilter)
        {
            if (conditionFilter == null)
            {
                throw new EZNEWException("GlobalConditionFilter is null");
            }
            if (conditionFilter.EntityType == null)
            {
                throw new EZNEWException("GlobalConditionFilter.EntityType is null");
            }
            if (conditionFilter.OriginalQuery == null)
            {
                conditionFilter.OriginalQuery = Create();
                conditionFilter.OriginalQuery.SetEntityType(conditionFilter.EntityType);
            }
            GlobalCondition globalCondition = null;

            if (GetGlobalConditionProxy != null && conditionFilter.OriginalQuery.AllowSetGlobalCondition())
            {
                globalCondition = GetGlobalConditionProxy(conditionFilter);
            }
            return(globalCondition);
        }