Beispiel #1
0
 private void SetSearchWhere(Context context, SiteSettings ss, SqlWhereCollection where)
 {
     if (Search.IsNullOrEmpty())
     {
         return;
     }
     where.FullTextWhere(
         ss: ss,
         tableName: ss.ReferenceType,
         searchText: Search);
 }
 private void SetSearchWhere(
     Context context,
     SiteSettings ss,
     SqlWhereCollection where,
     bool itemJoin)
 {
     if (Search.IsNullOrEmpty())
     {
         return;
     }
     where.FullTextWhere(
         ss: ss,
         searchText: Search,
         itemJoin: itemJoin);
 }
        /// <summary>
        /// Fixed:
        /// </summary>
        public static SqlWhereCollection FullTextWhere(
            this SqlWhereCollection where,
            Context context,
            SiteSettings ss,
            string searchText,
            bool itemJoin)
        {
            var name = Strings.NewGuid();

            if (ss != null && ss.TableType != Sqls.TableTypes.Normal)
            {
                return(where.ItemWhereLike(
                           context: context,
                           ss: ss,
                           columnName: "FullText",
                           searchText: searchText,
                           name: name,
                           forward: false,
                           itemJoin: itemJoin));
            }
            switch (ss?.SearchType)
            {
            case SiteSettings.SearchTypes.FullText:
                var words = Words(searchText);
                if (words?.Any() != true)
                {
                    return(where);
                }
                if (itemJoin)
                {
                    where.FullTextWhere(
                        context: context,
                        words: words,
                        itemsTableName: ss.ReferenceType + "_Items");
                }
                else
                {
                    where.FullTextWhere(
                        context: context,
                        words: words,
                        idColumnBracket: ss.IdColumnBracket(),
                        tableType: ss.TableType);
                }
                return(where);

            case SiteSettings.SearchTypes.MatchInFrontOfTitle:
                return(where.ItemWhereLike(
                           context: context,
                           ss: ss,
                           columnName: "Title",
                           searchText: searchText,
                           name: name,
                           forward: true,
                           itemJoin: itemJoin));

            case SiteSettings.SearchTypes.BroadMatchOfTitle:
                return(where.ItemWhereLike(
                           context: context,
                           ss: ss,
                           columnName: "Title",
                           searchText: searchText,
                           name: name,
                           forward: false,
                           itemJoin: itemJoin));

            case SiteSettings.SearchTypes.PartialMatch:
            default:
                return(where.ItemWhereLike(
                           context: context,
                           ss: ss,
                           columnName: "FullText",
                           searchText: searchText,
                           name: name,
                           forward: false,
                           itemJoin: itemJoin));
            }
        }