当前位置: 首页>>代码示例>>C#>>正文


C# CombinedQuery.Add方法代码示例

本文整理汇总了C#中CombinedQuery.Add方法的典型用法代码示例。如果您正苦于以下问题:C# CombinedQuery.Add方法的具体用法?C# CombinedQuery.Add怎么用?C# CombinedQuery.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CombinedQuery的用法示例。


在下文中一共展示了CombinedQuery.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddFieldValueClause

        internal static void AddFieldValueClause(CombinedQuery query, string fieldName, string fieldValue, QueryOccurance occurance)
        {
            if (fieldName.IsNullOrEmpty() || fieldValue.IsNullOrEmpty())
            {
                return;
            }

            fieldValue = IdHelper.ProcessGUIDs(fieldValue);
            query.Add(new FieldQuery(fieldName, fieldValue), occurance);
        }
开发者ID:udt1106,项目名称:Sitecore-Item-Buckets,代码行数:10,代码来源:SearcherMethods.cs

示例2: CreateQuery

        private QueryBase CreateQuery(Database database)
        {
            var query = new CombinedQuery();
            var databaseQuery = new FieldQuery(BuiltinFields.Database, database.Name);
            var languageQuery = new FieldQuery(BuiltinFields.Language, Context.Language.Name);
            var templateQuery = new FieldQuery(BuiltinFields.Template, ShortID.Encode(RewriteReportItem.TemplateId));

            query.Add(databaseQuery, QueryOccurance.Must);
            query.Add(languageQuery, QueryOccurance.Must);
            query.Add(templateQuery, QueryOccurance.Must);

            return query;
        }
开发者ID:SemionMcAlice,项目名称:UrlRewrite,代码行数:13,代码来源:ReportingHelper.cs

示例3: FieldSearch

        public SitecoreSearchResultCollection FieldSearch(QueryInfo[] qis, int maxResults)
        {
            HighResTimer timer = new HighResTimer(true);
            var combinedQuery = new CombinedQuery();
            foreach (var qi in qis)
            {
                var q = GetQuery(qi);
                if (q != null)
                    combinedQuery.Add(q, qi.SitecoreSearchQueryOccurance);
            }

            SearchResultCollection results = null;

            if (combinedQuery.Clauses.Count > 0)
                results = GetSearchHits(combinedQuery, maxResults);

            return results != null
                    ? new SitecoreSearchResultCollection(results, timer.Elapsed())
                    : null;
        }
开发者ID:JimmieOverby,项目名称:IndexViewer,代码行数:20,代码来源:SitecoreSearcher.cs

示例4: ApplyTemplateFilter

        internal static void ApplyTemplateFilter(CombinedQuery query, IEnumerable<Guid> templateIds)
        {
            if (templateIds == null || !templateIds.Any())
            {
                return;
            }

            var ids = templateIds as Guid[] ?? templateIds.ToArray();

            if (ids.Count() > 1)
            {
                var filterQuery = new CombinedQuery();
                foreach (var templateId in ids.Select(IdHelper.NormalizeGuid))
                {
                    filterQuery.Add(new FieldQuery(BuiltinFields.Template, templateId), QueryOccurance.Should);
                }

                query.Add(filterQuery, QueryOccurance.Must);
            }
            else
            {
                query.Add(new FieldQuery(BuiltinFields.Template, IdHelper.NormalizeGuid(ids.First())), QueryOccurance.Must);
            }
        }
开发者ID:csteeg,项目名称:Sitecore-Item-Buckets,代码行数:24,代码来源:SearcherMethods.cs

示例5: ApplyTemplateFilter

        protected void ApplyTemplateFilter(CombinedQuery query, string templateIds, QueryOccurance occurance)
        {
            if (String.IsNullOrEmpty(templateIds)) return;

            templateIds = IdHelper.NormalizeGuid(templateIds);
            var fieldQuery = new FieldQuery(BuiltinFields.Template, templateIds);
            query.Add(fieldQuery, occurance);
        }
开发者ID:mebinum,项目名称:AdvanceDb,代码行数:8,代码来源:SearchParam.cs

示例6: ApplyFullTextClause

        protected void ApplyFullTextClause(CombinedQuery query, string searchText, QueryOccurance occurance)
        {
            if (String.IsNullOrEmpty(searchText)) return;

            query.Add(new FullTextQuery(searchText), occurance);
        }
开发者ID:mebinum,项目名称:AdvanceDb,代码行数:6,代码来源:SearchParam.cs

示例7: ApplyRefinements

        protected void ApplyRefinements(CombinedQuery query, SafeDictionary<string> refinements, QueryOccurance occurance)
        {
            if (refinements.Count <= 0) return;

             var innerQuery = new CombinedQuery();

             foreach (var refinement in refinements)
             {
            var fieldName = refinement.Key.ToLowerInvariant();
            var fieldValue = refinement.Value;
            AddFieldValueClause(innerQuery, fieldName, fieldValue, occurance);
             }

             query.Add(innerQuery, QueryOccurance.Must);
        }
开发者ID:golden86,项目名称:ItemBuckets,代码行数:15,代码来源:Searcher.cs

示例8: GetBlogEntries

        /// <summary>
        /// Gets blog entries for the given blog up to the maximum number given
        /// </summary>
        /// <param name="blog">The blog item to get the entries for</param>
        /// <param name="maxNumber">The maximum number of entries to retrieve</param>
        /// <param name="tag">A tag the entry must contain</param>
        /// <param name="category">A category the entry must contain</param>
        /// <param name="minimumDate">The minimum date for entries</param>
        /// <param name="maximumDate">The maximum date for the entries</param>
        /// <returns></returns>
        public EntryItem[] GetBlogEntries(Item blog, int maxNumber, string tag, string category, DateTime? minimumDate = null, DateTime? maximumDate = null)
        {
            if (blog == null || maxNumber <= 0)
            {
                return new EntryItem[0];
            }

            BlogHomeItem customBlogItem = null;
            if (blog.TemplateIsOrBasedOn(Settings.BlogTemplateID))
            {
                customBlogItem = blog;
            }
            else
            {
                customBlogItem = blog.GetCurrentItem(Settings.BlogTemplateIDString);
            }
            if (customBlogItem == null)
            {
                return new EntryItem[0];
            }


            List<EntryItem> result = new List<EntryItem>();
#if FEATURE_CONTENT_SEARCH
            var indexName = Settings.SearchIndexName;
            if (!string.IsNullOrEmpty(indexName))
            {

              using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
                {
                    var builder = PredicateBuilder.True<EntryResultItem>();
                
                    var id = customBlogItem.BlogSettings.EntryTemplateID;
                    builder = builder.And(i => i.TemplateId == id);
                    builder = builder.And(i => i.Paths.Contains(customBlogItem.ID));
                    builder = builder.And(i => i.Language.Equals(customBlogItem.InnerItem.Language.Name, StringComparison.InvariantCulture));
                    builder = builder.And(item => item.DatabaseName.Equals(Context.Database.Name, StringComparison.InvariantCulture));

                    // Tag
                    if (!string.IsNullOrEmpty(tag))
                    {
                        builder = builder.And(i => i.Tags.Contains(tag));
                    }

                    // Categories
                    if (!string.IsNullOrEmpty(category))
                    {
                      var categoryItem = ManagerFactory.CategoryManagerInstance.GetCategory(customBlogItem, category);

                      // If the category is unknown, don't return any results.
                      if (categoryItem == null)
                          return new EntryItem[0];
#if SC70
                      var normalizedID = Sitecore.ContentSearch.Utilities.IdHelper.NormalizeGuid(categoryItem.ID);
                      builder = builder.And(i => i.Category.Contains(normalizedID));
#else
                      builder = builder.And(i => i.Category.Contains(categoryItem.ID));
#endif
                        
                    }

                    if (minimumDate != null)
                      builder = builder.And(i => i.CreatedDate >= minimumDate);

                    if(maximumDate != null)
                      builder = builder.And(i => i.CreatedDate < maximumDate);
                    
                    var indexresults = context.GetQueryable<EntryResultItem>().Where(builder);
                
                    if (indexresults.Any())
                    {
                        result = indexresults.Select(i => new EntryItem(i.GetItem())).ToList();
                        result = result.OrderByDescending(post => post.EntryDate.DateTime).Take(maxNumber).ToList();
                    }
                }
            }
#else
            var query = new CombinedQuery();
            //query.Add(new FieldQuery(Constants.Index.Fields.BlogID, blog.ID.ToShortID().ToString().ToLower()), QueryOccurance.Must);
            query.Add(new FieldQuery(Sitecore.Search.BuiltinFields.Path, customBlogItem.ID.ToShortID().ToString()), QueryOccurance.Must);
            query.Add(new FieldQuery(Constants.Index.Fields.Template, customBlogItem.BlogSettings.EntryTemplateID.ToShortID().ToString().ToLower()), QueryOccurance.Must);

            if (!string.IsNullOrEmpty(tag))
            {
                query.Add(new FieldQuery(Constants.Index.Fields.Tags, DatabaseCrawler.TransformCSV(tag)), QueryOccurance.Must);
            }

            if (!string.IsNullOrEmpty(category))
            {
                var categoryItem = ManagerFactory.CategoryManagerInstance.GetCategory(blog, category);
//.........这里部分代码省略.........
开发者ID:KerwinMa,项目名称:WeBlog,代码行数:101,代码来源:EntryManager.cs

示例9: GetCommentsFor

        /// <summary>
        /// Gets the comments for the given blog entry
        /// </summary>
        /// <param name="item">The item to get the comments under</param>
        /// <param name="maximumCount">The maximum number of comments to retrieve</param>
        /// <param name="language">The language to get the comments in</param>
        /// <returns>The comments which are decendants of the given item</returns>
        public CommentItem[] GetCommentsFor(Item item, int maximumCount, bool sort = false, bool reverse = false)
        {
            if (item != null && maximumCount > 0)
            {
                var blog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(item);
                if (blog != null)
                {
                    var query = new CombinedQuery();

                    // TODO: What about items using templates derived from commenttemplateid? need to accommodate those
                    query.Add(new FieldQuery(Constants.Index.Fields.Template, blog.BlogSettings.CommentTemplateID.ToShortID().ToString().ToLower()), QueryOccurance.Must);
                    query.Add(new FieldQuery(Sitecore.Search.BuiltinFields.Path, item.ID.ToShortID().ToString()), QueryOccurance.Must);

                    string sortField = null;
                    if (sort)
                    {
                        sortField = Constants.Index.Fields.Created;
                    }

                    var searcher = new Searcher();
                    return searcher.Execute<CommentItem>(query, maximumCount, (list, listItem) => list.Add((CommentItem)listItem), sortField, reverse);
                }
            }

            return new CommentItem[0];
        }
开发者ID:kaytee821,项目名称:WeBlog,代码行数:33,代码来源:CommentManager.cs

示例10: ApplyIdFilter

        internal static void ApplyIdFilter(CombinedQuery query, string fieldName, string filter)
        {
            if (fieldName.IsNullOrEmpty() || filter.IsNullOrEmpty())
            {
                return;
            }

            var filterQuery = new CombinedQuery();
            IdHelper.ParseId(filter).Where(IdHelper.IsGuid).ForEach(value => AddFieldValueClause(filterQuery, fieldName, value, QueryOccurance.Should));
            query.Add(filterQuery, QueryOccurance.Must);
        }
开发者ID:udt1106,项目名称:Sitecore-Item-Buckets,代码行数:11,代码来源:SearcherMethods.cs

示例11: ApplyFullTextClause

        internal static void ApplyFullTextClause(CombinedQuery query, string searchText, string indexName)
        {
            if (searchText.IsNullOrEmpty())
            {
                return;
            }

            var combinedQuery = new CombinedQuery();
            combinedQuery.Add(new FullTextQuery(searchText), QueryOccurance.Should);
            combinedQuery.Add(new FieldQuery(BuiltinFields.Name, searchText), QueryOccurance.Should);
            if (!indexName.IsNullOrEmpty())
            {
                AppendIndexSpecificTerms(combinedQuery, indexName, searchText);
            }

            query.Add(combinedQuery, QueryOccurance.Must);
        }
开发者ID:udt1106,项目名称:Sitecore-Item-Buckets,代码行数:17,代码来源:SearcherMethods.cs

示例12: GetCommentsFor

        /// <summary>
        /// Gets the comments for the given blog entry
        /// </summary>
        /// <param name="item">The item to get the comments under</param>
        /// <param name="maximumCount">The maximum number of comments to retrieve</param>
        /// <param name="language">The language to get the comments in</param>
        /// <returns>The comments which are decendants of the given item</returns>
        public CommentItem[] GetCommentsFor(Item item, int maximumCount, bool sort = false, bool reverse = false)
        {
            if (item != null && maximumCount > 0)
            {
                var blog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(item);
                if (blog != null)
                {
            #if FEATURE_CONTENT_SEARCH
                    var indexName = Settings.SearchIndexName;
                    List<CommentItem> result = new List<CommentItem>();
                    if (!string.IsNullOrEmpty(indexName))
                    {

                        using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext())
                        {
                            var builder = PredicateBuilder.True<CommentResultItem>();

                            builder = builder.And(i => i.DatabaseName == Context.Database.Name);
                            builder = builder.And(i => i.Language == Context.Language.Name);
                            builder = builder.And(i => i.Paths.Contains(item.ID));
                            builder = builder.And(i => i.TemplateId == Settings.CommentTemplateID);

                            var indexresults = context.GetQueryable<CommentResultItem>().Where(builder);
                            if (indexresults.Any())
                            {
                                result = indexresults.Select(i => new CommentItem(i.GetItem())).ToList();
                                if (sort && reverse)
                                {
                                    result = result.OrderByDescending(x => x.Created).ToList();
                                }
                                else if (sort)
                                {
                                    result = result.OrderBy(x => x.Created).ToList();
                                }

                                result = result.Take(maximumCount).ToList();
                            }
                        }
                    }
                    return result.ToArray();
            #else
                    var query = new CombinedQuery();

                    // TODO: What about items using templates derived from commenttemplateid? need to accommodate those
                    query.Add(new FieldQuery(Constants.Index.Fields.Template, blog.BlogSettings.CommentTemplateID.ToShortID().ToString().ToLower()), QueryOccurance.Must);
                    query.Add(new FieldQuery(Sitecore.Search.BuiltinFields.Path, item.ID.ToShortID().ToString()), QueryOccurance.Must);
                    query.Add(new FieldQuery(Sitecore.Search.BuiltinFields.Language, item.Language.Name), QueryOccurance.Must);

                    string sortField = null;
                    if (sort)
                    {
                        sortField = Constants.Index.Fields.Created;
                    }

                    var searcher = new Searcher();
                    return searcher.Execute<CommentItem>(query, maximumCount, (list, listItem) => list.Add((CommentItem)listItem), sortField, reverse);
            #endif
                }
            }
            return new CommentItem[0];
        }
开发者ID:TCUK-London,项目名称:WeBlog,代码行数:68,代码来源:CommentManager.cs

示例13: GetBlogEntries

        /// <summary>
        /// Gets blog entries for the given blog up to the maximum number given
        /// </summary>
        /// <param name="blog">The blog item to get the entries for</param>
        /// <param name="maxNumber">The maximum number of entries to retrieve</param>
        /// <param name="tag">A tag the entry must contain</param>
        /// <param name="category">A category the entry must contain</param>
        /// <returns></returns>
        public EntryItem[] GetBlogEntries(Item blog, int maxNumber, string tag, string category, string datePrefix = null)
        {
            if (blog == null || maxNumber <= 0)
            {
                return new EntryItem[0];
            }

            BlogHomeItem customBlogItem = null;
            if (blog.TemplateIsOrBasedOn(Settings.BlogTemplateID))
            {
                customBlogItem = blog;
            }
            else
            {
                customBlogItem = blog.GetCurrentItem(Settings.BlogTemplateIDString);
            }
            if (customBlogItem == null)
            {
                return new EntryItem[0];
            }

            var query = new CombinedQuery();
            //query.Add(new FieldQuery(Constants.Index.Fields.BlogID, blog.ID.ToShortID().ToString().ToLower()), QueryOccurance.Must);
            query.Add(new FieldQuery(Sitecore.Search.BuiltinFields.Path, customBlogItem.ID.ToShortID().ToString()), QueryOccurance.Must);
            query.Add(new FieldQuery(Constants.Index.Fields.Template, customBlogItem.BlogSettings.EntryTemplateID.ToShortID().ToString().ToLower()), QueryOccurance.Must);

            if (!string.IsNullOrEmpty(tag))
            {
                query.Add(new FieldQuery(Constants.Index.Fields.Tags, DatabaseCrawler.TransformCSV(tag)), QueryOccurance.Must);
            }

            if (!string.IsNullOrEmpty(category))
            {
                var categoryItem = ManagerFactory.CategoryManagerInstance.GetCategory(blog, category);
                ID id = ID.Null;

                if (categoryItem != null)
                    id = categoryItem.ID;

                query.Add(new FieldQuery(Constants.Index.Fields.Category, id.ToShortID().ToString().ToLower()), QueryOccurance.Must);
            }

            if (!string.IsNullOrEmpty(datePrefix))
            {
                query.Add(new FieldQuery(Constants.Index.Fields.Created, datePrefix + "*"), QueryOccurance.Must);
            }

            var searcher = new Searcher();
            var result = searcher.Execute<EntryItem>(query, maxNumber, (list, item) => list.Add((EntryItem)item), Constants.Index.Fields.EntryDate, true);

            return result;
        }
开发者ID:Quatra,项目名称:WeBlog,代码行数:60,代码来源:EntryManager.cs

示例14: GetCommentsFor

        /// <summary>
        /// Gets the comments for the given blog entry
        /// </summary>
        /// <param name="item">The item to get the comments under</param>
        /// <param name="maximumCount">The maximum number of comments to retrieve</param>
        /// <param name="language">The language to get the comments in</param>
        /// <returns>The comments which are decendants of the given item</returns>
        public CommentItem[] GetCommentsFor(Item item, int maximumCount, bool sort = false, bool reverse = false)
        {
            if (item != null && maximumCount > 0)
            {
                var blog = ManagerFactory.BlogManagerInstance.GetCurrentBlog(item);
                if (blog != null)
                {
#if FEATURE_CONTENT_SEARCH
                    var indexName = Settings.SearchIndexName;
                    List<CommentItem> result = new List<CommentItem>();
                    if (!string.IsNullOrEmpty(indexName))
                    {
                        using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext())
                        {
                            var indexresults = context.GetQueryable<CommentResultItem>().Where(x => 
                              x.Paths.Contains(item.ID) &&
                              x.TemplateId == blog.BlogSettings.CommentTemplateID &&
                              x.DatabaseName.Equals(Context.Database.Name, StringComparison.InvariantCulture) &&
                              x.Language == item.Language.Name
                              );
                            if (indexresults.Any())
                            {
                              if(sort)
                                indexresults = indexresults.OrderByDescending(x => x.CreatedDate);
                                
                              else if (reverse)
                                indexresults = indexresults.OrderBy(x => x.CreatedDate);

                              indexresults = indexresults.Take(maximumCount);

                              // Had some odd issues with the linq layer. Array to avoid them.
                              var indexresultsList = indexresults.ToArray();

                              var items = from resultItem in indexresultsList
                                let i = resultItem.GetItem()
                                where i != null
                                select i;

                              result = items.Select(x => new CommentItem(x)).ToList();
                            }
                        }
                    }
                    return result.ToArray();

                  
#else
                    var query = new CombinedQuery();

                    // TODO: What about items using templates derived from commenttemplateid? need to accommodate those
                    query.Add(new FieldQuery(Constants.Index.Fields.Template, blog.BlogSettings.CommentTemplateID.ToShortID().ToString().ToLower()), QueryOccurance.Must);
                    query.Add(new FieldQuery(Sitecore.Search.BuiltinFields.Path, item.ID.ToShortID().ToString()), QueryOccurance.Must);
                    query.Add(new FieldQuery(Sitecore.Search.BuiltinFields.Language, item.Language.Name), QueryOccurance.Must);

                    string sortField = null;
                    if (sort)
                    {
                        sortField = Constants.Index.Fields.Created;
                    }

                    var searcher = new Searcher();
                    return searcher.Execute<CommentItem>(query, item.Language, maximumCount, (list, listItem) => list.Add((CommentItem)listItem), sortField, reverse);
#endif
                }
            }
            return new CommentItem[0];
        }
开发者ID:KerwinMa,项目名称:WeBlog,代码行数:73,代码来源:CommentManager.cs

示例15: ApplyContextItemRemoval

 internal static void ApplyContextItemRemoval(CombinedQuery query, IEnumerable<Guid> ids)
 {
     if (ids == null || !ids.Any())
     {
         return;
     }
     ids.ForEach(id => query.Add(new FieldQuery(BuiltinFields.ID, IdHelper.NormalizeGuid(id)), QueryOccurance.MustNot));
 }
开发者ID:csteeg,项目名称:Sitecore-Item-Buckets,代码行数:8,代码来源:SearcherMethods.cs


注:本文中的CombinedQuery.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。