public async Task <IDictionary <Guid, Apprenticeship> > Execute(DocumentClient client, Configuration configuration, GetApprenticeships request) { var collectionUri = UriFactory.CreateDocumentCollectionUri( configuration.DatabaseId, configuration.ApprenticeshipCollectionName); var query = client.CreateDocumentQuery <Apprenticeship>(collectionUri, new FeedOptions() { EnableCrossPartitionQuery = true }) .Where(p => p.RecordStatus != 4 && p.RecordStatus != 8); if (request.Predicate != null) { query = query.Where(request.Predicate); } var results = await query.AsDocumentQuery().FetchAll(); var resultsDict = results.ToDictionary(r => r.Id, r => r); return(resultsDict); }
public IDictionary <Guid, Apprenticeship> Execute(InMemoryDocumentStore inMemoryDocumentStore, GetApprenticeships request) { var query = inMemoryDocumentStore.Apprenticeships.All.AsQueryable(); if (request.Predicate != null) { query = query.Where(request.Predicate); } return(query.ToDictionary(a => a.Id, a => a)); }