Exemplo n.º 1
0
 /// <summary>
 /// When overidden, determines whether the specified field is included in the data set.
 /// </summary>
 /// <param name="fieldName">Field name.</param>
 /// <returns>Returns *true* if the specified field is included in the data set.</returns>
 public override bool HasField(string fieldName)
 {
     string[] mappedNames = SearchServiceHelper.GetManagedPropertyNames(this.Site, fieldName);
     if (mappedNames.Length > 0)
     {
         fieldName = mappedNames[0];
     }
     return(base.HasField(fieldName));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Gets or sets values to the specified column.
 /// </summary>
 /// <param name="name">Field name.</param>
 /// <returns>Value of the specified column.</returns>
 protected override object this[string name] {
     get {
         string[] mappedNames = SearchServiceHelper.GetManagedPropertyNames(this.Site, name);
         if (mappedNames.Length > 0)
         {
             name = mappedNames[0];
         }
         object value = base[name];
         if (value != DBNull.Value)
         {
             return(value);
         }
         return(null);
     }
     set {
         base[name] = value;
     }
 }
Exemplo n.º 3
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);
        }