/// <summary>
        /// The result feld map from crm query.
        /// </summary>
        /// <param name="crmQuery">
        /// The crm query.
        /// </param>
        /// <returns>
        /// The <see cref="Dictionary"/>.
        /// </returns>
        Dictionary <string, int> ResultFeldMapFromCrmQuery(UPContainerMetaInfo crmQuery)
        {
            if (crmQuery == null)
            {
                return(null);
            }

            var resultFieldMap = new Dictionary <string, int>(this.FieldDictionary.Count);

            foreach (var fieldKey in this.FieldDictionary)
            {
                int pos = crmQuery.PositionForField(this.FieldDictionary[fieldKey.Key]);
                resultFieldMap.Add(fieldKey.Key, pos);
            }

            return(resultFieldMap);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigExpandConditionForQuery"/> class.
        /// </summary>
        /// <param name="condition">The condition.</param>
        /// <param name="crmQuery">The CRM query.</param>
        /// <param name="alternate">The alternate.</param>
        public UPConfigExpandConditionForQuery(UPConfigExpandCondition condition, UPContainerMetaInfo crmQuery, UPConfigExpandAlternate alternate)
            : base(condition, alternate)
        {
            this.ResultPosition = crmQuery?.PositionForField(this.Field) ?? 0;
            if (!this.FieldValue.StartsWith("$cur") && !this.FieldValue.StartsWith("$par"))
            {
                return;
            }

            var dateFieldValue = this.FieldValue.ReplaceDateVariables();

            if (dateFieldValue.StartsWith("$"))
            {
                var replaceValues = UPConditionValueReplacement.SessionParameterReplacements().ValueOrDefault(this.FieldValue);
                if (replaceValues != null && replaceValues.Count > 0)
                {
                    this.FieldValue = replaceValues[0];
                }
            }
            else
            {
                this.FieldValue = dateFieldValue;
            }
        }