public async Task <IList <ResourceStore> > GetSearch(Common.Enums.FhirVersion fhirVersion, Common.Enums.ResourceType resourceType, IList <ISearchQueryBase> searchQueryList) { ExpressionStarter <ResourceStore> Predicate = IPredicateFactory.CurrentMainResource(fhirVersion, resourceType); Predicate.Extend(await IPredicateFactory.GetResourceStoreIndexPredicate(fhirVersion, resourceType, searchQueryList), PredicateOperator.And); foreach (var exp in await IPredicateFactory.ChainEntry(_context, resourceType, searchQueryList)) { Predicate.Extend(exp, PredicateOperator.And); } try { IQueryable <ResourceStore> Query = DbSet; Query = Query.AsExpandable().Where(Predicate); return(await Query.OrderBy(z => z.LastUpdated).ToListAsync()); } catch (Exception Exec) { var mesg = Exec.Message; throw Exec; } //string Debug = Predicate.Expand().ToString(); //return await Predicate2.AsExpandable().Where(Predicate).OrderBy(z => z.LastUpdated).ToListAsync(); }
public async Task <Expression <Func <ResourceStore, bool> > > CompositeIndex(IPredicateFactory IPredicateFactory, SearchQueryComposite SearchQueryComposite) { var ResourceStorePredicate = LinqKit.PredicateBuilder.New <ResourceStore>(true); foreach (SearchQueryCompositeValue CompositeValue in SearchQueryComposite.ValueList) { if (!SearchQueryComposite.Modifier.HasValue) { if (CompositeValue.SearchQueryBaseList is null) { throw new ArgumentNullException(nameof(CompositeValue.SearchQueryBaseList)); } ResourceStorePredicate = ResourceStorePredicate.Or(await IPredicateFactory.GetResourceStoreIndexPredicate(SearchQueryComposite.FhirVersionId, SearchQueryComposite.ResourceContext, CompositeValue.SearchQueryBaseList)); } else { throw new ApplicationException($"Internal Server Error: The search query modifier: {SearchQueryComposite.Modifier.Value.GetCode()} is not supported for search parameter types of {SearchQueryComposite.SearchParamTypeId.GetCode()}."); } } return(ResourceStorePredicate); }