Пример #1
0
        /// <summary>
        /// Deep copy source SearchCriterion
        /// </summary>
        /// <param name="source">Copy source</param>
        /// <returns>Deep copied instance</returns>
        public static SearchCriterion Copy(SearchCriterion source)
        {
            SearchCriterion target = new SearchCriterion();

            target.ColumnType   = source.ColumnType;
            target.Name         = source.Name;
            target.OperatorType = source.OperatorType;
            target.TerminalType = source.TerminalType;
            target.Value        = source.Value;
            target.Hashable     = source.Hashable;
            target.Values.AddRange(source.Values);

            return(target);
        }
Пример #2
0
        /// <summary>
        /// Deep copy source SearchCriteria
        /// </summary>
        /// <param name="source">Copy source</param>
        /// <returns>Deep copied instance</returns>
        public static SearchCriteria Copy(SearchCriteria source)
        {
            if (source == null)
            {
                return(null);
            }

            SearchCriteria target = new SearchCriteria();

            foreach (SearchCriterion criterion in source.CriterionList)
            {
                SearchCriterion targetCriterion = SearchCriterion.Copy(criterion);
                target.CriterionList.Add(targetCriterion);
            }

            return(target);
        }
Пример #3
0
        /// <summary>
        /// Create WHERE clause from seach criteria
        /// </summary>
        /// <param name="appendWhere">Flag of add WHERE clause</param>
        /// <returns>WHERE caluse</returns>
        public string CreateWhereClauseString(bool appendWhere)
        {
            if (CriterionList.Count == 0)
            {
                return("");
            }

            StringBuilder builder = new StringBuilder();

            if (appendWhere)
            {
                builder.Append(" where (");
            }
            else
            {
                builder.Append(" and (");
            }

            for (int i = 0; i < CriterionList.Count; i++)
            {
                SearchCriterion criterion = CriterionList[i];

                if (i != 0)
                {
                    if (criterion.TerminalType == SearchCriterion.TerminalTypeEnum.And)
                    {
                        builder.Append(" and ");
                    }
                    else
                    {
                        builder.Append(" or ");
                    }
                }

                builder.Append(criterion.GetWhereStatementWithParam(i.ToString()));
            }

            builder.Append(")");

            return(builder.ToString());
        }