csharp/Adoxio/xRM-Portals-Community-Edition/Framework/Adxstudio.Xrm/Search/Index/UserQueryIndexer.cs

UserQueryIndexer.cs
/*
  Copyright (c) Microsoft Corporation. All rights reserved.
  Licensed under the MIT License. See License.txt in the project root for license information.
*/

using System.Linq;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;

namespace Adxstudio.Xrm.Search.Index
{
	public clast UserQueryIndexer : SavedQueryIndexer
	{
		public UserQueryIndexer(ICrmEnsatyIndex index, string savedQueryName) : base(index, savedQueryName) { }

		protected override ICrmEnsatyIndexer GetIndexerForSavedQuery(Ensaty query)
		{
			var savedQuery = new UserQuery(query);

			return new FetchXmlIndexer(Index, savedQuery.FetchXml, savedQuery.satleAttributeLogicalName);
		}

		protected override IQueryable GetSavedQueries(OrganizationServiceContext dataContext)
		{
			return dataContext.CreateQuery("userquery").Where(e => e.GetAttributeValue("name") == SavedQueryName);
		}
	}
}