/// <summary>
        /// The equals.
        /// </summary>
        /// <param name="obj">
        /// The obj.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null || this.GetType() != obj.GetType())
            {
                return(false);
            }

            SearchSavedQuery item = obj as SearchSavedQuery;

            return(item.SavedQueryId == this.SavedQueryId);
        }
        /// <summary>
        /// Query CRM to get Portal Search Enabled entities
        /// </summary>
        /// <returns>
        /// The search enabled entities.
        /// </returns>
        public HashSet <string> GetPortalSearchEnabledEntities()
        {
            this.SearchEnabledEntities = new HashSet <string>();
            this.SearchSavedQueries    = new HashSet <SearchSavedQuery>();

            FilterExpression filterExpression = new FilterExpression();

            filterExpression.AddCondition("name", ConditionOperator.Equal, this.GetSearchSavedQueryViewName());
            filterExpression.AddCondition("componentstate", ConditionOperator.Equal, 0);
            QueryExpression query = new QueryExpression()
            {
                EntityName = "savedquery",
                ColumnSet  = new ColumnSet("returnedtypecode", "savedqueryidunique"),
                Criteria   = filterExpression
            };
            var request = new RetrieveMultipleRequest()
            {
                Query = query
            };
            var response = (RetrieveMultipleResponse)this.OrganizationServiceContext.Execute(request);
            var entities = response.EntityCollection.Entities;

            foreach (Entity entity in entities)
            {
                var savedQueryItem = new SearchSavedQuery(entity);
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Entity {0} has Portal Search View Present in CRM ", savedQueryItem.EntityName));
                this.SearchEnabledEntities.Add(savedQueryItem.EntityName);
                this.SearchSavedQueries.Add(savedQueryItem);
            }

            // These entities are not searchable but changes to them can invalidate certain searchable entities
            List <string> searchAffectingEntities = new List <string>()
            {
                "adx_webpageaccesscontrolrule",
                "adx_communityforumaccesspermission",
                "connection",
                "adx_contentaccesslevel",
                "adx_knowledgearticlecontentaccesslevel",
                "adx_webpageaccesscontrolrule_webrole",
                "adx_website",
                "savedquery"
            };

            searchAffectingEntities.ForEach(x => this.SearchEnabledEntities.Add(x));
            return(this.SearchEnabledEntities);
        }
 /// <summary>
 /// The complete metadata update for search saved query.
 /// </summary>
 /// <param name="savedQuery">
 /// The saved query.
 /// </param>
 /// <param name="newUniqueId">
 /// The new unique id.
 /// </param>
 public void CompleteMetadataUpdateForSearchSavedQuery(SearchSavedQuery savedQuery, Guid newUniqueId)
 {
     savedQuery.SavedQueryIdUnique = newUniqueId;
 }