Exemple #1
0
        /// <inheritdoc />
        protected override async Task <IReadOnlyDictionary <string, IReadOnlyCollection <IModel> > > GetItem(string id, CancellationToken cancellationToken = default)
        {
            // Get the models
            var models = await m_provider
                         // Query the models from a given book
                         .GetBookModelsAsync(IdToInt(id), cancellationToken)
                         // Materialize the result
                         .ToListAsync(cancellationToken)
                         .ConfigureAwait(false);

            // Return the result
            return(models
                   // Group the models by their names
                   .GroupBy(model => model.Name)
                   // Materialize the items into a map of model name to concrete models
                   .ToDictionary(group => group.Key, group => group.ToReadOnlyCollection()));
        }