private IEnumerable <IValueSetBackingItem> QueryValueSetBackingItems( IReadOnlyCollection <Guid> valueSetGuids, IReadOnlyCollection <Guid> codeSystemGuids) { var factory = new ValueSetBackingItemFactory(); try { if (!valueSetGuids.Any()) { return(new List <IValueSetBackingItem>()); } var dtos = this.DbSet.Where(dto => valueSetGuids.Contains(dto.ValueSetGUID)); if (codeSystemGuids.Any()) { var vsGuids = this.sharedContext.ValueSetCodes .Where(code => codeSystemGuids.Contains(code.CodeSystemGuid)) .Select(code => code.ValueSetGUID) .Distinct(); dtos = dtos.Join(vsGuids, dto => dto.ValueSetGUID, key => key, (dto, key) => dto); } return(dtos.Select(dto => factory.Build(dto)).ToList()); } catch (Exception ex) { this.logger.Error(ex, "Failed to query ValueSetDescriptions by collection of ValueSetGUID"); throw; } }
public Maybe <IValueSet> GetValueSet(Guid valueSetGuid) { return(this.uowManager.GetValueSetDescriptionDto(valueSetGuid) .Select( dto => { var factory = new ValueSetBackingItemFactory(); var item = factory.Build(dto, true); var codes = this.GetCodes(item.ValueSetGuid); var counts = this.GetCodeCounts(item.ValueSetGuid); return new ValueSet(item, codes, counts) as IValueSet; })); }
private IEnumerable <IValueSetBackingItem> QueryValueSetBackingItems(string valueSetReferenceId) { var factory = new ValueSetBackingItemFactory(); try { return(this.DbSet.Where(dto => dto.ValueSetReferenceID == valueSetReferenceId) .AsNoTracking() .Select(dto => factory.Build(dto)) .ToList()); } catch (Exception ex) { this.logger.Error(ex, "Failed to query ValueSetDescriptions by collection of ValueSetReferenceId"); throw; } }
private async Task <PagedCollection <IValueSetBackingItem> > CreatePagedCollectionAsync( IQueryable <ValueSetDescriptionDto> source, IPagerSettings pagerSettings) { var defaultItemsPerPage = this.sharedContext.Settings.DefaultItemsPerPage; var pagingStrategy = this.pagingStrategyFactory.GetPagingStrategy <IValueSetBackingItem>(defaultItemsPerPage); pagingStrategy.EnsurePagerSettings(pagerSettings); var count = await source.CountAsync().ConfigureAwait(false); var items = await source.Skip((pagerSettings.CurrentPage - 1) *pagerSettings.ItemsPerPage) .Take(pagerSettings.ItemsPerPage) .ToListAsync().ConfigureAwait(false); var factory = new ValueSetBackingItemFactory(); return(pagingStrategy.CreatePagedCollection( items.Select(i => this.cacheManager.GetOrSet(i.ValueSetGUID, () => factory.Build(i))).Values(), count, pagerSettings)); }