Exemple #1
0
        /// <summary>
        /// Generazione della stringa di query relativa alla ricerca di un
        /// valore in un campo impostato come fulltext
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="items"></param>
        /// <returns></returns>
        public string GetContainsTextQuery(string fieldName, params DocsPaVO.filtri.SearchTextItem[] items)
        {
            string retValue = "CONTAINS(" + fieldName + ", ";

            string searchText = "'";

            bool append = false;

            DocsPaUtils.Data.FullTextUtils fullTextUtils = new SqlFullTextUtils();

            foreach (DocsPaVO.filtri.SearchTextItem item in items)
            {
                if (append)
                {
                    searchText += " AND ";
                }

                searchText += "''";

                if (item.SearchOption == DocsPaVO.filtri.SearchTextOptionsEnum.WholeWord)
                {
                    searchText += fullTextUtils.ParseTextSpecialChars(item.TextToSearch.Trim());
                }
                else if (item.SearchOption == DocsPaVO.filtri.SearchTextOptionsEnum.InitWithWord)
                {
                    searchText += fullTextUtils.ParseTextSpecialChars(item.TextToSearch.Trim()) + "*";
                }
                else if (item.SearchOption == DocsPaVO.filtri.SearchTextOptionsEnum.ContainsWord)
                {
                    searchText += "*" + fullTextUtils.ParseTextSpecialChars(item.TextToSearch.Trim()) + "*";
                }

                searchText += "''";

                append = true;
            }

            retValue += searchText + "')";

            return(retValue);
        }
Exemple #2
0
        /// <summary>
        /// Generazione della stringa di query relativa alla ricerca di un
        /// valore in un campo impostato come fulltext
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public string GetContainsTextQuery(string fieldName, string value)
        {
            string retValue   = "contains(" + fieldName + ", ";
            string searchText = "'";

            DocsPaUtils.Data.FullTextUtils fullTextUtils = new SqlFullTextUtils();

            searchText += value.Trim();
            searchText  = fullTextUtils.ParseTextSpecialChars(searchText);

            retValue += searchText + "') > 0";

            return(retValue);
        }