Example #1
0
 /// <summary>
 /// Performs a keyword search against the items of the associated content type(s) and returns the number of items.
 /// </summary>
 /// <typeparam name="TItem">Item type.</typeparam>
 /// <param name="query">CAML query expression.</param>
 /// <param name="keywords">A list of keywords to be searched against.</param>
 /// <param name="refiners">A list of <see cref="SearchRefiner"/> instances. Refinement results are populated to the supplied instances.</param>
 /// <param name="keywordInclusion">See <see cref="KeywordInclusion"/>.</param>
 /// <returns>Number of items.</returns>
 public new int GetCount <TItem>(CamlExpression query, string[] keywords, SearchRefiner[] refiners, KeywordInclusion keywordInclusion)
 {
     return(base.GetCount <TItem>(query, keywords, refiners, keywordInclusion));
 }
 public SPModelQueryProvider(ISPModelManagerInternal manager, string[] keywords, KeywordInclusion keywordInclusion)
     : this(manager) {
     this.useOfficeSearch  = true;
     this.keywords         = keywords;
     this.keywordInclusion = keywordInclusion;
 }
Example #3
0
 /// <summary>
 /// Performs a keyword search against the items of the associated content type(s).
 /// </summary>
 /// <typeparam name="TItem">Item type.</typeparam>
 /// <param name="query">CAML query expression.</param>
 /// <param name="limit">Maximum number of items to be returned.</param>
 /// <param name="startRow">Number of items to skip from start.</param>
 /// <param name="keywords">A list of keywords to be searched against.</param>
 /// <param name="refiners">A list of <see cref="SearchRefiner"/> instances. Refinement results are populated to the supplied instances.</param>
 /// <param name="keywordInclusion">See <see cref="KeywordInclusion"/>.</param>
 /// <param name="totalCount">Total number of items.</param>
 /// <returns>A collection containing the returned items.</returns>
 public new SPModelCollection <TItem> GetItems <TItem>(CamlExpression query, uint limit, uint startRow, string[] keywords, SearchRefiner[] refiners, KeywordInclusion keywordInclusion, out int totalCount)
 {
     return(base.GetItems <TItem>(query, limit, startRow, keywords, refiners, keywordInclusion, out totalCount));
 }
Example #4
0
 /// <summary>
 /// Performs a keyword search against the items of the associated content type(s) and returns the number of items.
 /// </summary>
 /// <param name="query">CAML query expression.</param>
 /// <param name="keywords">A list of keywords to be searched against.</param>
 /// <param name="keywordInclusion">See <see cref="KeywordInclusion"/>.</param>
 /// <returns>Number of items.</returns>
 public int GetCount(CamlExpression query, string[] keywords, KeywordInclusion keywordInclusion)
 {
     return(base.GetCount <T>(query, keywords, keywordInclusion));
 }
Example #5
0
 /// <summary>
 /// Performs a keyword search against the items of the associated content type(s).
 /// </summary>
 /// <typeparam name="TItem">Item type.</typeparam>
 /// <param name="query">CAML query expression.</param>
 /// <param name="limit">Maximum number of items to be returned.</param>
 /// <param name="keywords">A list of keywords to be searched against.</param>
 /// <param name="keywordInclusion">See <see cref="KeywordInclusion"/>.</param>
 /// <returns>A collection containing the returned items.</returns>
 public new SPModelCollection <TItem> GetItems <TItem>(CamlExpression query, uint limit, string[] keywords, KeywordInclusion keywordInclusion)
 {
     return(base.GetItems <TItem>(query, limit, keywords, keywordInclusion));
 }
Example #6
0
        public static IQueryable <T> Query <T>(this ISPModelManager manager, string[] keywords, KeywordInclusion keywordInclusion)
        {
            Type modelType = ((ISPModelManagerInternal)manager).Descriptor.ModelType;
            Type queryType = typeof(SPModelQuery <>).MakeGenericType(modelType);

            return(((IQueryable)queryType.CreateInstance(new SPModelQueryProvider((ISPModelManagerInternal)manager, keywords, keywordInclusion))).OfType <T>());
        }
Example #7
0
 public static IQueryable <T> Query <T>(this SPModelManagerBase <T> manager, string[] keywords, KeywordInclusion keywordInclusion)
 {
     return(new SPModelQuery <T>(new SPModelQueryProvider(manager, keywords, keywordInclusion)));
 }
Example #8
0
        /// <summary>
        /// Executes a CAML query against Office search service.
        /// </summary>
        /// <param name="site">A site collection object.</param>
        /// <param name="query">A CAML expression.</param>
        /// <param name="limit">Number of rows to be returned.</param>
        /// <param name="startRow">Number of rows to be skipped.</param>
        /// <param name="keywords">A list of keywords to be passed in query text.</param>
        /// <param name="refiners">A list of <see cref="SearchRefiner"/> objects where refinement results are populated.</param>
        /// <param name="inclusion">Whether to match all or any keywords supplied.</param>
        /// <param name="selectProperties">A list of managed properties to be returned.</param>
        /// <returns>Results returned from Office search service.</returns>
        public static ResultTable ExecuteQuery(SPSite site, CamlExpression query, int limit, int startRow, string[] keywords, SearchRefiner[] refiners, KeywordInclusion inclusion, string[] selectProperties)
        {
            KeywordQuery keywordQuery = CreateQuery(site, query, limit, startRow, keywords, inclusion, selectProperties);

            return(ExecuteQuery(keywordQuery, refiners));
        }
Example #9
0
        /// <summary>
        /// Creates a <see cref="KeywordQuery"/> instance with query text and certain properties set in regards of the specified CAML expression.
        /// </summary>
        /// <param name="site">A site collection object.</param>
        /// <param name="query">A CAML expression.</param>
        /// <param name="limit">Number of rows to be returned.</param>
        /// <param name="startRow">Number of rows to be skipped.</param>
        /// <param name="keywords">A list of keywords to be passed in query text.</param>
        /// <param name="inclusion">Whether to match all or any keywords supplied.</param>
        /// <param name="selectProperties">A list of managed properties to be returned.</param>
        /// <returns>A prepared <see cref="KeywordQuery"/> instance.</returns>
        public static KeywordQuery CreateQuery(SPSite site, CamlExpression query, int limit, int startRow, string[] keywords, KeywordInclusion inclusion, string[] selectProperties)
        {
            CommonHelper.ConfirmNotNull(site, "site");
            KeywordQuery keywordQuery = SearchServiceHelper.CreateKeywordQueryFromCaml(site, query);

            if (keywords != null)
            {
                keywordQuery.QueryText = String.Concat(String.Join(" ", keywords), " ", keywordQuery.QueryText);
            }
            keywordQuery.SelectProperties.AddRange(SPModel.RequiredSearchProperties);
            if (selectProperties != null)
            {
                keywordQuery.SelectProperties.AddRange(selectProperties);
            }
            keywordQuery.KeywordInclusion         = inclusion;
            keywordQuery.ResultsProvider          = SearchProvider.Default;
            keywordQuery.TrimDuplicates           = true;
            keywordQuery.TrimDuplicatesOnProperty = BuiltInManagedPropertyName.UniqueID;
            keywordQuery.StartRow    = startRow;
            keywordQuery.RowLimit    = limit;
            keywordQuery.RowsPerPage = limit;
            return(keywordQuery);
        }