/// <summary>
        /// Prefetches a collection of generic attributes for a range of entities in one go
        /// and caches them for the duration of the current request.
        /// </summary>
        /// <param name="entities">The entity instances to prefetch attributes for.</param>
        public static async Task PrefetchAttributesAsync(this IGenericAttributeService service, params BaseEntity[] entities)
        {
            Guard.NotNull(service, nameof(service));

            var groupedEntities = entities.GroupBy(x => x.GetEntityName());

            foreach (var group in groupedEntities)
            {
                await service.PrefetchAttributesAsync(group.Key, group.Select(x => x.Id).ToArray());
            }
        }